如何在CakePHP表单中创建自己的名称属性?

时间:2015-11-13 07:02:03

标签: cakephp cakephp-3.0

我正在使用CakePHP 3.我想生成自己的样式输入标记。我的代码是:

     <?php
echo $this->Form->input(
                   'rpassword', array(
                   'class' => 'form-control placeholder-no-fix',
                   'type' => 'password',
                    'autocomplete' => 'off',
                    'placeholder' => 'Re-type Your New Password'
                   )
              );
        ?>

它生成HTML如下:

 <input name="data[Reseller][rpassword]" class="form-control placeholder-no-fix " autocomplete="off" placeholder="Re-type Your New Password" type="password" id="ResellerRpassword" >

但我想将name属性设置为'rpassword'。我期望的HTML是:

 <input name="rpassword" class="form-control placeholder-no-fix " autocomplete="off" placeholder="Re-type Your New Password" type="password" id="ResellerRpassword" >

有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

您可以在name参数中设置input属性,例如'name' => 'rpassword': -

echo $this->Form->input(
    'rpassword', array(
        'class' => 'form-control placeholder-no-fix',
        'type' => 'password',
        'name' => 'rpassword',
        'autocomplete' => 'off',
        'placeholder' => 'Re-type Your New Password'
    )
);