如何在fuelphp中管理多个表单模板
你好,我刚从CI迁移到Fuel。。。。我正在使用Fieldset类在视图中自动生成表单。。。。我面临的问题是,我有多种类型的表单模板,例如,我的一些模型使用twitter引导水平内联表单,只有少数模型使用自定义模板。。。我能够在form.php中设置单一类型的表单模板,并将其从fuel/core/config/form.php复制到fuel/app/config/form.php 下面是表单模板的返回数组示例如何在fuelphp中管理多个表单模板,php,forms,fuelphp,Php,Forms,Fuelphp,你好,我刚从CI迁移到Fuel。。。。我正在使用Fieldset类在视图中自动生成表单。。。。我面临的问题是,我有多种类型的表单模板,例如,我的一些模型使用twitter引导水平内联表单,只有少数模型使用自定义模板。。。我能够在form.php中设置单一类型的表单模板,并将其从fuel/core/config/form.php复制到fuel/app/config/form.php 下面是表单模板的返回数组示例 return array( // regular form definitions '
return array(
// regular form definitions
'prep_value' => true,
'auto_id' => true,
'auto_id_prefix' => 'form_',
'form_method' => 'post',
'form_template' => "\n\t\t{open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{close}\n",
'fieldset_template' => "\n\t\t<tr><td colspan=\"2\">{open}<table>\n{fields}</table></td></tr>\n\t\t{close}\n",
'field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} <span>{description}</span> {error_msg}</td>\n\t\t</tr>\n",
'multi_field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}<span>{description}</span>\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n",
'error_template' => '<span>{error_msg}</span>',
'group_label' => '<span>{label}</span>',
'required_mark' => '*',
'inline_errors' => false,
'error_class' => null,
'label_class' => null,
// tabular form definitions
'tabular_form_template' => "<table>{fields}</table>\n",
'tabular_field_template' => "{field}",
'tabular_row_template' => "<tr>{fields}</tr>\n",
'tabular_row_field_template' => "\t\t\t<td>{label}{required} {field} {error_msg}</td>\n",
'tabular_delete_label' => "Delete?",
返回数组(
//正则形式定义
“准备值”=>true,
'auto_id'=>true,
“自动识别前缀”=>“格式”,
“form_method”=>“post”,
'form\u template'=>“\n\t\t{open}\n\t\t\n{fields}\n\t\t\n\t\t{close}\n”,
'fieldset_template'=>“\n\t\t{open}\n{fields}\n\t\t{close}\n”,
'field\u template'=>“\t\t\n\t\t{label}{required}\n\t\t\t{field}{description}{error\u msg}\n\t\t\n”,
“多字段模板”=>“\t\t\n\t\t\t{group\u label}{required}\n\t\t\t{fields}\n\t\t\t\t{field}{label}
\n{fields}{description}\t\t\t{error\u msg}\n\t\t\t\t\n\t\t\t\n”,
'error\u template'=>'{error\u msg}',
'group_label'=>'{label}',
'必选标记'=>'*',
“内联_错误”=>false,
'error_class'=>null,
'label_class'=>null,
//表格形式定义
'表格表格模板'=>“{fields}\n”,
'表格字段模板'=>“{field}”,
“表格行模板”=>“{fields}\n”,
'tabular_row_field_template'=>“\t\t\t{label}{required}{field}{error\u msg}\n”,
“表格删除标签”=>“删除?”,
))
我想要多个这样的表单模板,这样我就能够使用$fieldset->form()->build()函数自动生成需要的表单
有没有办法做到这一点 是的。试试这个:
forge($name='default',$config=array())
$article\u form=Fieldset::forge('article',数组(
//正则形式定义
“准备值”=>true,
'auto_id'=>true,
“自动识别前缀”=>“格式”,
“form_method”=>“post”,
'form\u template'=>“\n\t\t{open}\n\t\t\n{fields}\n\t\t\n\t\t{close}\n”,
'fieldset_template'=>“\n\t\t{open}\n{fields}\n\t\t{close}\n”,
'field\u template'=>“\t\t\n\t\t{label}{required}\n\t\t\t{field}{description}{error\u msg}\n\t\t\n”,
“多字段模板”=>“\t\t\n\t\t\t{group\u label}{required}\n\t\t\t{fields}\n\t\t\t\t{field}{label}
\n{fields}{description}\t\t\t{error\u msg}\n\t\t\t\t\n\t\t\t\n”,
'error\u template'=>'{error\u msg}',
'group_label'=>'{label}',
'必选标记'=>'*',
“内联_错误”=>false,
'error_class'=>null,
'label_class'=>null,
//表格形式定义
'表格表格模板'=>“{fields}\n”,
'表格字段模板'=>“{field}”,
“表格行模板”=>“{fields}\n”,
'tabular_row_field_template'=>“\t\t\t{label}{required}{field}{error\u msg}\n”,
“表格删除标签”=>“删除?”,
));
是。试试这个:
forge($name='default',$config=array())
$article\u form=Fieldset::forge('article',数组(
//正则形式定义
“准备值”=>true,
'auto_id'=>true,
“自动识别前缀”=>“格式”,
“form_method”=>“post”,
'form\u template'=>“\n\t\t{open}\n\t\t\n{fields}\n\t\t\n\t\t{close}\n”,
'fieldset_template'=>“\n\t\t{open}\n{fields}\n\t\t{close}\n”,
'field\u template'=>“\t\t\n\t\t{label}{required}\n\t\t\t{field}{description}{error\u msg}\n\t\t\n”,
“多字段模板”=>“\t\t\n\t\t\t{group\u label}{required}\n\t\t\t{fields}\n\t\t\t\t{field}{label}
\n{fields}{description}\t\t\t{error\u msg}\n\t\t\t\t\n\t\t\t\n”,
'error\u template'=>'{error\u msg}',
'group_label'=>'{label}',
'必选标记'=>'*',
“内联_错误”=>false,
'error_class'=>null,
'label_class'=>null,
//表格形式定义
'表格表格模板'=>“{fields}\n”,
'表格字段模板'=>“{field}”,
“表格行模板”=>“{fields}\n”,
'tabular_row_field_template'=>“\t\t\t{label}{required}{field}{error\u msg}\n”,
“表格删除标签”=>“删除?”,
));
正是我需要的Thanx@EmRa正是我需要的Thanx@EmRa正是我需要的Thanx@EmRa
$article_form = Fieldset::forge('article',array(
// regular form definitions
'prep_value' => true,
'auto_id' => true,
'auto_id_prefix' => 'form_',
'form_method' => 'post',
'form_template' => "\n\t\t{open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{close}\n",
'fieldset_template' => "\n\t\t<tr><td colspan=\"2\">{open}<table>\n{fields}</table></td></tr>\n\t\t{close}\n",
'field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} <span>{description}</span> {error_msg}</td>\n\t\t</tr>\n",
'multi_field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}<span>{description}</span>\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n",
'error_template' => '<span>{error_msg}</span>',
'group_label' => '<span>{label}</span>',
'required_mark' => '*',
'inline_errors' => false,
'error_class' => null,
'label_class' => null,
// tabular form definitions
'tabular_form_template' => "<table>{fields}</table>\n",
'tabular_field_template' => "{field}",
'tabular_row_template' => "<tr>{fields}</tr>\n",
'tabular_row_field_template' => "\t\t\t<td>{label}{required} {field} {error_msg}</td>\n",
'tabular_delete_label' => "Delete?",
));