Using CakePHP FormHelper with Bootstrap Forms

前端 未结 9 605
天命终不由人
天命终不由人 2020-12-12 14:56

CakePHP\'s FormHelper is how you generate forms when making CakePHP applications. As one might assume, this includes generating input elements, like so:

$thi         


        
9条回答
  •  时光取名叫无心
    2020-12-12 15:17

    To get it working with a horizontal form in bootstrap with bootswatch I had to use:

    echo $this->Form->create(
        'User',
        array(
            'action'        => 'add',
            'admin'         => 'false',
            'class'         => 'form-horizontal',
            'inputDefaults' => array(
                'format'  => array( 'before', 'label', 'between',
                                    'input', 'error', 'after' ),
                'class' => 'form-control',
                'div'     => array( 'class' => 'form-group' ),
                'label'   => array( 'class' => 'col-lg-2 control-label' ),
                'between' => '
    ', 'after' => '
    ', 'error' => array( 'attributes' => array( 'wrap' => 'span', 'class' => 'text-danger' ) ), ) ) );

    Then you can just use it as normal:

    echo $this->Form->input( 'User.username' );
    

提交回复
热议问题