2013-06-23 96 views
0

我想定义自定义标签的形式输入:标签形式输入

<?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' => '')); 

    ?> 

的形式显示“我的回答”,而不是“选择一个答案”。如果无线电选项被删除,表单按预期工作。任何指针?

回答

0

没有使用与单选按钮的标准标签选项的方式,但它很容易在你的视图中添加与使用表单标签功能:

如何使用FormHelper::label(string $fieldName, string $text, array $options)您可以定义标签类的选项阵列中,因此(例如):

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')) 

也可以参考详细文档CakePHP Cookbook on FormHelper