ako rucne v sablone vykreslit formular vytvoreny v presenteri cez tovarnu
- stewe
- Člen | 20
Zdravim,
som v Nette totalny zelenac, principy som ako tak pochopil ale jedna vec mi vobec nedochadza.
Vytvoril som si v presenteri tovarnu na registracny formular
<?php
class SignupPresenter extends BasePresenter {
public function createComponentSignUpForm() {
$form = new Form;
$form->addText('username', 'Username:')
->addRule(Form::FILLED, 'Enter your username')
->setRequired('Please provide a username');
$form->addText('email', 'E-mail:')
->setEmptyValue('@')
->addCondition(Form::FILLED)
->addRule(Form::EMAIL, 'E-mail address is not valid');
$form->addPassword('password', 'Password:')
->addRule(Form::FILLED, 'Choose a password')
->addRule(Form::MIN_LENGTH, 'Password has to be at least %d characters long.', 6)
->setRequired('Please provide a password');
$form->addPassword('password2', 'Repeat password:')
->addRule(Form::FILLED, 'Enter your password here one more time for to be sure')
->addRule(Form::EQUAL, 'Entered passwords are not equal', $form['password']);
$form->addSubmit('send', 'Sign up');
$form->addProtection('Time is up. Fill in your registration form once again.');
$form->onSuccess[] = callback($this, 'signUpFormSubmitted');
return $form;
}
...
?>
ten formular si vykreslim v sablone / layoute default.latte pre ten presenter
<body>
{block #content}
<h1>Sign up</h1>
{widget signUpForm}
</body>
Ide ale o to, ze neviem, ako vykreslit v sablone ten formular „po mojom“. Takto sa vykresli automaticky, ja chcem mat pristup k jednotlivym labelom / prvkom formulara a vykreslit si ich po mojom.
Staci mi principialne ako to spravit. Dakujem za radu
Editoval stewe (2. 7. 2011 23:03)
- stewe
- Člen | 20
no jo, lenze ako dostanem do tej sablony default.latte ten formular?
ked dam nieco ako
<body>
{block #content}
<h1>Sign in</h1>
<?php $form->['username']->label ?>
</body>
tak na mna vybafne debugger, ze $form proste neexistuje, aj ked to teda prepisem na default.phtml.
Kde sa dostanem v sablone k tej $form premennej?
=========================
AHA :D
{form signUpForm}
<table>
<tr class="required">
<th>{label username /}</th>
</tr>
</table>
{/form signUpForm}
Editoval stewe (2. 7. 2011 22:59)
- stewe
- Člen | 20
ako este zakomponovat do tej .latte sablony vypis chyb?
nieco ako
<?php
$form->render('begin')
$form->render('errors')
?>
cez aky „prvok“ toho signUp formulara, sa k nim v tom .latte dostanem? Lebo ked to chcem vypisat cez php, tak ten $form nepozna …
Editoval stewe (2. 7. 2011 23:14)