diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 0ddd5229b..407606604 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -68,6 +68,7 @@ class Form implements SmartyPluginInterface $instance = $this->getInstance($params['name']); $instance = $instance->buildForm($formBuilder, array()); + $template->assign("form", $instance->getForm()->createView()); } else { return $content; @@ -86,8 +87,15 @@ class Form implements SmartyPluginInterface } + $template->assign("options", $form->vars); $template->assign("name", $form->vars["name"]); $template->assign("value", $form->vars["value"]); + $template->assign("label", $form->vars["label"]); + $attr = array(); + foreach ($form->vars["attr"] as $key => $value) { + $attr[] = sprintf('%s="%s"', $key, $value); + } + $template->assign("attr", implode(" ", $attr)); $form->setRendered(); @@ -110,7 +118,7 @@ class Form implements SmartyPluginInterface $return = ""; foreach ($form->getIterator() as $row) { - if ($this->isHidden($row)) { + if ($this->isHidden($row) && $row->isRendered() === false) { $return .= sprintf($field, $row->vars["name"], $row->vars["value"]); } } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 4c70a0177..98e3dd0eb 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -32,7 +32,13 @@ class CustomerCreation extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { return $builder->add("name", "text") - ->add("email", "email") + ->add("email", "email", array( + "attr" => array( + "class" => "field" + ), + "label" => "toto" + ) + ) ->add('age', 'integer'); } diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 89b1c63d6..1aaa0b9e6 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -12,11 +12,11 @@ An image from asset directory : {form_field_hidden form=$form} {form_field form=$form.email} - {intl l='email'} : + {intl l='{$label}'} : {/form_field} {form_field form=$form.name} - {intl l='name'} : + {intl l='name'} : {/form_field} {form_field form=$form.age} {intl l='age'} :