add smarty function form_enctype
This commit is contained in:
@@ -85,6 +85,7 @@ class Form implements SmartyPluginInterface
|
||||
Symfony\Component\Form\FormView");
|
||||
}
|
||||
|
||||
|
||||
$template->assign("name", $form->vars["name"]);
|
||||
$template->assign("value", $form->vars["value"]);
|
||||
|
||||
@@ -95,7 +96,7 @@ class Form implements SmartyPluginInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function formRenderHidden($params, $template)
|
||||
public function formRenderHidden($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$form = $params["form"];
|
||||
|
||||
@@ -122,6 +123,20 @@ class Form implements SmartyPluginInterface
|
||||
return array_search("hidden", $formView->vars["block_prefixes"]);
|
||||
}
|
||||
|
||||
public function formEnctype($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$form = $params["form"];
|
||||
|
||||
if (! $form instanceof \Symfony\Component\Form\FormView) {
|
||||
throw new \InvalidArgumentException("form parameter in form_field block must be an instance of
|
||||
Symfony\Component\Form\FormView");
|
||||
}
|
||||
|
||||
if ($form->vars["multipart"]) {
|
||||
return sprintf('%s="%s"',"enctype", "multipart/form-data");
|
||||
}
|
||||
}
|
||||
|
||||
public function getInstance($name)
|
||||
{
|
||||
if (!isset($this->formDefinition[$name])) {
|
||||
@@ -140,7 +155,8 @@ class Form implements SmartyPluginInterface
|
||||
return array(
|
||||
new SmartyPluginDescriptor("block", "form", $this, "generateForm"),
|
||||
new SmartyPluginDescriptor("block", "form_field", $this, "formRender"),
|
||||
new SmartyPluginDescriptor("function", "form_field_hidden", $this, "formRenderHidden")
|
||||
new SmartyPluginDescriptor("function", "form_field_hidden", $this, "formRenderHidden"),
|
||||
new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ class CustomerCreation extends AbstractType
|
||||
{
|
||||
return $builder->add("name", "text")
|
||||
->add("email", "email")
|
||||
->add('age', 'integer')
|
||||
;
|
||||
->add('age', 'integer');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,9 @@ An image from asset directory :
|
||||
<div>
|
||||
{intl l='An internationalized string'}
|
||||
</div>
|
||||
<form method="post" action="index_dev.php" >
|
||||
{form name="thelia.customer.creation"}
|
||||
<form method="post" action="index_dev.php" {form_enctype form=$form} >
|
||||
|
||||
{form_field_hidden form=$form}
|
||||
{form_field form=$form.email}
|
||||
{intl l='email'} : <input type="text" name="{$name}">
|
||||
@@ -20,8 +21,8 @@ An image from asset directory :
|
||||
{form_field form=$form.age}
|
||||
{intl l='age'} : <input type="text" name="{$name}">
|
||||
{/form_field}
|
||||
{/form}
|
||||
</form>
|
||||
{/form}
|
||||
<div>
|
||||
jQuery data: <span id="jquery_block"></span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user