Cakephp 表单输入标签

Cakephp 表单输入标签,cakephp,cakephp-2.1,Cakephp,Cakephp 2.1,我想为表单输入定义一个自定义标签: <?php echo $this->Form->create('Question'); ?> <?php echo $this->Form->input('my_answer', array('label' => 'Select an answer', 'type' => 'radio', 'options' => array($question['Quest

我想为表单输入定义一个自定义标签:

<?php echo $this->Form->create('Question'); ?>

    <?php
    echo $this->Form->input('my_answer', array('label' => 'Select an answer',
            'type' => 'radio', 'options' => array($question['Question']['answer_choice1'], $question['Question']['answer_choice2'], 'value' => ''));

    ?>


没有一种方法可以将标准标签选项与单选按钮一起使用,但使用表单标签功能可以很容易地在视图中添加:

使用
FormHelper::label(string$fieldName,string$text,array$options)
您可以在options数组中定义label类,因此(例如):

您还可以参考详细文档了解更多信息

echo $options = array( /* relevant stuff goes here */ );
echo $attributes = array( /* relevant stuff goes here */ );
echo $this->Form->radio('gender', $options, $attributes);
echo $this->Form->label('gender', 'Text of your label', array('label'=>'radioBtn'))