Demo · Forms

Default Style Example block-level help text here.

$Form=new Form;
echo $Form->init('#','post')
    ->head('Default Style')
    ->group('Label Name',
        new Text(array('placeholder'=>'Type something...')),
        new Help('Example block-level help text here.'),
        new Checkbox('Check me out', array('checked'=>true)),
        new Submit()
    )
    ->render();
$Form=new Form;
echo $Form->init('#','post',array(
        'class'=>'form-search'
    ))
    ->head('Search Forms')
    ->group('',
        new Text(array('class'=>'input-medium search-query')),
        new Submit('Search')
    )
    ->group('',
        new Text(array(
            'class'     => 'input-medium search-query',
            'append'    => new Button('Search')
        ))
    )
    ->render();
Inline Form

$Form=new Form;
echo $Form->init('#','post',array(
        'class'=>'form-inline'
    ))
    ->head('Inline Form')
    ->group('',
        new Text(array(
            'placeholder'=>'Email',
            'class'=>'input-small'
        )),
        new Password(array(
            'placeholder'=>'Password',
            'class'=>'input-small'
        )),
        new Checkbox('Remember me'),
        new Submit('Sign In')
    )
    ->render();
Horizontal Form
This is a login form!

$Form=new Form;
echo $Form->init('#', 'post', array(
        'class'=>'form-horizontal'
    ))
    ->head('Horizontal Form')
    ->group('Email',
        new Text(array(
            'placeholder'   => 'Email',
            'id'            => 'inputEmail'
        ))
    )
    ->group('Password',
        new Password(array(
            'placeholder'   => 'Password',
            'id'            => 'inputPassword'
        )),
        new Help('This is a login form!')
    )
    ->group('',
        new Checkbox('Remember me', array(
            'checked'   => true
        )),
        new Submit('Sign in', array(
            'class' => 'btn'
        ))
    )
    ->render();
Supported Form Controls
Hiddens are handled by the Form->hidden() function
@
$
@$

$Form=new Form;
echo $Form->init('#', 'post', array(
        'class' => 'form-horizontal'
    ))
    ->head('Supported Form Controls')
    ->hidden(array(
        'name'  => 'single-hidden',
        'value' => 'single-hidden-value',
        'id'    => 'single-hidden-id'
    ))
    ->hidden(array(array(
        'name'  => 'multiple-hidden-1',
        'value' => 'multiple-hidden-1-value'
        ), array(
        'name'  => 'multiple-hidden-2',
        'value' => 'multiple-hidden-2-value'
    )))
    ->group('Text', new Text())
    ->group('Password', new Password())
    ->group('Hidden', new Custom('Hiddens are handled by the Form->hidden() function'))
    ->group('Textarea', new Textarea('Default text'))
    ->group('Checkboxes',
        new Checkbox('Checkbox 1'),
        new Checkbox('Checkbox 2')
    )
    ->group('Radios',
        new Radio('Radio 1'),
        new Radio('Radio 2')
    )
    ->group('Inline Checkboxes',
        new Checkbox('Checkbox 1', array(
            'checked'   => true
        ), true),
        new Checkbox('Checkbox 2', array(), true)
    )
    ->group('Select',
        new Select(array(
            1,2,3
        ), 1)
    )
    ->group('Multiple Select',
        new Select(array(
            1,2,3
        ), array(0,2), array(
            'multiple'  => true
        ))
    )
    ->group('Prepended Input',
        new Text(array(
            'prepend'   => '@'
        ))
    )
    ->group('Appended Input',
        new Text(array(
            'append'   => '$'
        ))
    )
    ->group('Combined prepend & append',
        new Text(array(
            'prepend'   => '@',
            'append'    => '$'
        ))
    )
    ->group('Button Prepend',
        new Text(array(
            'prepend'   => new Button('Go!', array('type'=>'button','class'=>'btn'))
        ))
    )
    ->group('Button Append',
        new Text(array(
            'append'   => new Button('Go!', array('type'=>'submit', 'class'=>'1'))
        ))
    )
    ->group('Button append & prepend',
        new Text(array(
            'prepend'   => new Button('Go!', array('type'=>'button','class'=>'btn')),
            'append'    => new Button('Go2!', array('type'=>'button','class'=>'btn'))
        ))
    )
    ->group('Custom HTML',
        new Custom('Any HTML here')
    )
    ->actions(
        new Submit('Submit', array(
            'class' => 'btn-primary'
        )),
        new Reset()
    )
    ->render();