Amir Hossain
Amir Hossain

Reputation: 693

Cakephp formhelper with bootstrap horizontal form

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

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

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

Upvotes: 1

Views: 1572

Answers (1)

Amir Hossain
Amir Hossain

Reputation: 693

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

Upvotes: 2

Related Questions