I'm attempting to set the class on a class on a form label using php templates.
我正在尝试使用php模板在表单标签上的类上设置类。
Here's my code:
这是我的代码:
<?php echo $view['form']->label($form['first_name'], 'First Name', array(
'attr' => array('class' => 'control-label')
)) ?>
But here's my output:
但这是我的输出:
<label class="required" for="form_first_name">First name</label>
I can find how to do it using twig, but not an example with PHP.
我可以找到如何使用twig,但不是PHP的例子。
1 个解决方案
#1
58
I've got it...
我懂了...
<?php
echo $view['form']->label($form['first_name'], 'First Name', array(
'label_attr' => array('class' => 'control-label'),
))
?>
Apparently "attr" is "label_attr" for labels fields.
显然,“attr”是标签字段的“label_attr”。
P.S. Corresponding twig code
附:相应的树枝代码
{{ form_label(form.first_name, 'First Name', { 'label_attr': {'class': 'control-label'} }) }}
#1
58
I've got it...
我懂了...
<?php
echo $view['form']->label($form['first_name'], 'First Name', array(
'label_attr' => array('class' => 'control-label'),
))
?>
Apparently "attr" is "label_attr" for labels fields.
显然,“attr”是标签字段的“label_attr”。
P.S. Corresponding twig code
附:相应的树枝代码
{{ form_label(form.first_name, 'First Name', { 'label_attr': {'class': 'control-label'} }) }}