name all form field

This commit is contained in:
Manuel Raynaud
2013-07-01 11:54:40 +02:00
parent 26be670f57
commit 762b5bc71c
5 changed files with 26 additions and 3 deletions

View File

@@ -23,6 +23,7 @@
<forms>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.admin_login" class="Thelia\Form\AdminLogin"/>
</forms>

View File

@@ -90,8 +90,10 @@ class Form implements SmartyPluginInterface
$instance = $this->getInstance($params['name']);
$form = $instance->getForm();
if (true === $this->request->getSession()->get("form_error", false) && $this->request->getSession()->get
("form_name") == $instance->getName()) {
if (
true === $this->request->getSession()->get("form_error", false) &&
$this->request->getSession()->get("form_name") == $instance->getName())
{
$form->bind($this->request);
$this->request->getSession()->set("form_error", false);
}

View File

@@ -41,4 +41,9 @@ class AdminLogin extends BaseForm {
->add("password", "password");
}
public function getName()
{
return "admin_login";
}
}

View File

@@ -61,7 +61,7 @@ abstract class BaseForm {
)
->addExtension(new ValidatorExtension($validator))
->getFormFactory()
->createBuilder($type, $data, $options);
->createNamedBuilder($this->getName(), $type, $data, $options);
;

View File

@@ -27,6 +27,21 @@ An image from asset directory :
<input type="submit" value="valider">
</form>
{/form}
<br />
{form name="thelia.admin_login"}
<form method="post" action="#" {form_enctype form=$form} >
{form_field_hidden form=$form}
{form_field form=$form.username}
username : <input type="text" name="{$name}" {$attr}>
{/form_field}
{form_field form=$form.password}
password : <input type="password" name="{$name}" {$attr}>
{/form_field}
</form>
{/form}
<div>
jQuery data: <span id="jquery_block"></span>
</div>