iallow to display labek and attribute into form_field block
This commit is contained in:
@@ -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"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ An image from asset directory :
|
||||
|
||||
{form_field_hidden form=$form}
|
||||
{form_field form=$form.email}
|
||||
{intl l='email'} : <input type="text" name="{$name}">
|
||||
{intl l='{$label}'} : <input type="text" name="{$name}" {$attr} >
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form.name}
|
||||
{intl l='name'} : <input type="text" name="{$name}">
|
||||
{intl l='name'} : <input type="text" name="{$name}" >
|
||||
{/form_field}
|
||||
{form_field form=$form.age}
|
||||
{intl l='age'} : <input type="text" name="{$name}">
|
||||
|
||||
Reference in New Issue
Block a user