// --- 为表单中错误信息自动加上样式 ---
namespace Admin\Form\Helper; //对应文件夹
use Zend\Form\View\Helper\FormElementErrors as OriginalFormElementErrors;
class FormElementErrors extends OriginalFormElementErrors
{
protected $messageCloseString = '</li></ul>';
protected $messageOpenFormat = '<ul class="errors"%s><li>';
protected $messageSeparatorString = '</li><li>';
}
// --- 为multiCheckbox 的Label标签加上样式 ---
在/model/xxxForm.php
$this->add(array(
'type' => 'multiCheckbox',
'name' => 'location_code',
'options' => array(
'label' => '广告位置',
'value_options' => array(
'h_a1' => '首页广告1',
'h_a2' => '首页广告2',
'h_a3' => '首页广告3',
),
'label_attributes'=>array(
'class'=>'abc',
),
),
));
// --- 其它表单元素设置属性方法 ---
可查阅对应的 /zend/form/view/helper/表单元素类型.php 文件中查询属性
本文详细介绍了如何使用 Zend 框架为表单中的错误信息自动添加样式,并为多选框的 Label 标签自定义样式。涵盖了从表单元素错误信息的样式调整到多选框 Label 的外观定制。
866

被折叠的 条评论
为什么被折叠?



