cakephp表单输入autoFocus

时间:2014-06-02 02:40:24

标签: cakephp-2.5

我正在使用cakephp表单助手,我想设置输入属性autoFocus。我能得到的最好的是autoFocus =" autoFocus"这是无效的。我需要将其设置为autoFocus。

<input type="text" name="fname" autofocus>

我的代码是:

echo $this->Form->input('title', array('class'=>'form-control','autofocus'));

1 个答案:

答案 0 :(得分:3)

试试这个

<?php
    echo $this->Form->create('Staff', array('action' => 'login'));
    echo $this->Form->inputs(array(
        'legend' => __(''),
        'username' => array('autofocus'=>'autofocus'),
        'password'
    ));
    echo $this->Form->end('Login');
?>