El *_*ado 24 php forms label zend-framework2 zend-form2
我正在使用Zend/Form向我的页面添加表单.
我通过定义如下来添加元素:
$this->add(array(
'name' => 'value',
'attributes' => array(
'type' => 'text',
'id' => 'value',
'autocomplete' => 'off',
'placeholder' => 'Cost',
),
'options' => array(
'label' => 'Cost',
),
));
Run Code Online (Sandbox Code Playgroud)
如您所见,有一个'label'=>'cost'节点,这会生成一个与input元素一起使用的标签.
如何向此标签添加类,属性?
Sam*_*Sam 49
请尝试这个,我没有测试或使用过这个,但是从源头开始它应该正常运行:
$this->add(array(
'name' => 'value',
'attributes' => array(),
'options' => array(
'label_attributes' => array(
'class' => 'mycss classes'
),
// more options
),
));
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,请给我留言.如果它不起作用,则不可能使用这种方法,因为FormLabel限制了validAttributes很多:
protected $validTagAttributes = array(
'for' => true,
'form' => true,
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22453 次 |
| 最近记录: |