带有水平引导表格的Cakephp formhelper [英] Cakephp formhelper with bootstrap horizontal form

查看:61
本文介绍了带有水平引导表格的Cakephp formhelper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在之后,使用引导程序水平表单创建了基本表单。

I was creating a basic form using bootstrap horizontal form following this

一切正常,但是当我尝试使用密码类型并生成下拉列表时,它不起作用。根据cakephp文档,我需要重写InputDefaults,但是还没有运气。到目前为止我的代码

Everything works fine but when i was trying to use password type and generate dropdown it doesn't work. According to cakephp documentation i need to override InputDefaults,but no luck yet. My code so far

<?php echo $this->Form->create('User', 
        array('action' => 'registration', 'class'=>'form-horizontal',
            'inputDefaults'=>array(
                'format' => array('before', 'label', 'between', 'input', 'error', 'after'),  
                'div' => array('class' => 'form-group'),  
                'label' => array('class' => 'control-label col-sm-4'),  
                'between' => '<div class="col-sm-6">',  
                'after' => '</div>',
                'class'=>'form-control',
                'error' => array('attributes' => array('wrap' => 'span', 'class' => 'help-inline'))
            )
            )); 

echo $this->Form->input('user_pass', 
    array(
        'label'=>array('text'=>'Password','class'=>'control-label col-sm-4')            
    )
); 
echo $this->Form->input('question', array(
  'label'=>array('text'=>'Security Question','class'=>'control-label col-sm-4')
)
?>

我知道如果我更改$ this-> Form-> input('password'),它将适用于密码类型。但是我想使用user_paas,我知道如何使用generate dropdown

I know if i change $this->Form->input('password'),it will work for password type. but i want to use user_paas and I know how to use generate dropdown

  echo $this->Form->input('question',  array(
   'type' => 'select',
   'options' => $question,
   'class' =>'form-control',
    )
  );


推荐答案

我以某种方式错过了,在数组中传递类型和选项可以解决问题。

I somehow missed, passing type and option in array solves the problem.

echo $this->Form->input('re_pass', array('type' => 'password',
'label'=>array('text'=>'Retype Password','class'=>'control-label col-sm-4')
    )
);

echo $this->Form->input('question',  array('type' => 'select','options'=>$question, 
  'label'=>array('text'=>'Security question','class'=>'control-label col-sm-4')
    )
);

这篇关于带有水平引导表格的Cakephp formhelper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆