jakopo87 / BActiveForm

Active Form based on BootstrapYii

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BActiveForm

Active Form widget based on BootstrapYii.

Installation

First install the BootstrapYii component, then create a bActiveForm folder into the Yii's folder of extentions (default: protected/extentions).

Usage

To initialize the widget, do as follow:

    /* $this refers to the current controller */
    $form = $this->beginWidget('ext.bActiveForm.BActiveForm', array(
        'action' => 'url/to/action',
        'method' => 'METHOD',
    ));
    ...

To create an input controls:

    echo $form->textField($model,$attribute);

assuming $form=new ContactForm(); and $attribute='name', the generated markup will like this:

    <div class="form-group">
        <label class="control-label">Name</label>
        <input name="ContactForm[name]" id="ContactForm_name" type="text" class="form-control" />
    </div>

you can choose the size in columns of both label and control in this way:

    $form->textField($new ConcactForm(), 'name', array('sizes' => array('md' => 10), 'labelOptions' => array('sizes' => array('md' => 2))));
    <div class="form-group">
        <label class="control-label col-md-2">Name</label>
        <div class="col-md-10">
            <input name="ContactForm[name]" id="ContactForm_name" type="text" class="form-control" />
        </div>
    </div>

Finally close the widget with this line:

    /* $this refers to the current controller */
    $this->endWidget();

About

Active Form based on BootstrapYii

License:MIT License


Languages

Language:JavaScript 95.8%Language:PHP 3.7%Language:CSS 0.4%