如何设置表单输入的名称


How to set the name of a form input

我有以下内容:

$this->Form->input('type', array(
    'options' => array(
        'Blog',
        'Forum',
        'News',
        'Other'
    ),
    'empty' => '(Select a type)'
), array('title' => 'Select your websites type'));

但是标题不变,而是标题为"type"。如何更改标题?

我假设"title"是指输入的标签

 $this->Form->input('type', array(
                'options' => array('Blog',
                                   'Forum',
                                   'News',
                                   'Other'),
                  'empty' => '(Select a type)',
                  'label' => 'Select your websites type'));

如果你指的是html属性"title",并且不介意select的标签,那么

 $this->Form->input('type', array(
                'options' => array('Blog',
                                   'Forum',
                                   'News',
                                   'Other'),
                  'empty' => '(Select a type)',
                  'title' => 'Select your websites type'));

当然,你可以把它们混在一起。

如果您想将名称从'type'更改为其他名称,只需在代码中替换type即可:

$this->Form->input('NEW NAME HERE', array(
    'options' => array(
        'Blog',
        'Forum',
        'News',
        'Other'
    ),
    'empty' => '(Select a type)'
));