Zend Framework 2 module for easy integration of Twitter Bootstrap v2.3.2
This project is maintained by Neilime
This demonstration page shows how to render Twitter Boostrap elements. For each elements, you can see how to do it in "Source" tabs. These are supposed to be run into a view file.
$form = new \Zend\Form\Form();
$fieldset = new \Zend\Form\Fieldset('legend');
$form->add($fieldset->setLabel('Legend')->add(array(
'name' => 'input-text',
'attributes' => array(
'placeholder' => 'Type something...'
),
'options' => array(
'label' => 'Label name',
'twb' => array(
'help-block' => 'Example block-level help text here.'
)
)
))
->add(array(
'name' => 'input-checkbox',
'type' => 'checkbox',
'options' => array(
'label' => 'Check me out',
'use_hidden_element' => false
)
))
->add(array(
'name' => 'button-submit',
'type' => 'button',
'attributes' => array(
'type' => 'submit'
),
'options' => array(
'label' => 'Submit'
)
)));
echo $this->form($form,null);
$form = new \Zend\Form\Form();
$form->add(array(
'name' => 'input-text',
'attributes' => array(
'class' => 'search-query input-medium'
)
))
->add(array(
'name' => 'button-submit',
'type' => 'button',
'attributes' => array(
'type' => 'submit'
),
'options' => array(
'label' => 'Search'
)
));
echo $this->form($form,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_SEARCH);
$form = new \Zend\Form\Form();
$form->add(array(
'name' => 'input-text-email',
'attributes' => array(
'class' => 'input-small',
'placeholder' => 'Email'
)
))
->add(array(
'name' => 'input-text-password',
'attributes' => array(
'class' => 'input-small',
'placeholder' => 'Password'
)
))
->add(array(
'name' => 'input-checkbox',
'type' => 'checkbox',
'options' => array(
'label' => 'Remember me',
'use_hidden_element' => false
)
))
->add(array(
'name' => 'button-submit',
'type' => 'button',
'attributes' => array(
'type' => 'submit'
),
'options' => array(
'label' => 'Sign in'
)
));
echo $this->form($form,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE);
$form = new \Zend\Form\Form();
$form->add(array(
'name' => 'input-text-email',
'attributes' => array(
'class' => 'input-small',
'placeholder' => 'Email'
),
'options' => array(
'label' => 'Email'
)
))
->add(array(
'name' => 'input-text-password',
'attributes' => array(
'class' => 'input-small',
'placeholder' => 'Password'
),
'options' => array(
'label' => 'Password'
)
))
->add(array(
'name' => 'input-checkbox',
'type' => 'checkbox',
'options' => array(
'label' => 'Remember me',
'use_hidden_element' => false
)
))
->add(array(
'name' => 'button-submit',
'type' => 'button',
'attributes' => array(
'type' => 'submit'
),
'options' => array(
'label' => 'Sign in'
)
));
echo $this->form($form);
$elementPrepend = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'prepend' => '@'
)
));
$elementAppend = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'append' => '.00'
)
));
echo $this->formRow($elementPrepend);
echo $this->formRow($elementAppend);
$element = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'prepend' => '$',
'append' => '.00'
)
));
echo $this->formRow($element);
$elementOne = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'append' => array(
'type' => 'buttons',
'buttons' => array('go' => array('options' => array('label' => 'Go!')))
)
)
));
$elementTwo = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'append' => array(
'type' => 'buttons',
'buttons' => array(
'search' => array('options' => array('label' => 'Search')),
'options' => array('options' => array('label' => 'Options'))
)
)
)
));
echo $this->formRow($elementOne);
echo $this->formRow($elementTwo);
$elementPrepend = new \Zend\Form\Element('input-text',array(
'twb' => array(
'prepend' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
)
)
));
$elementAppend = new \Zend\Form\Element('input-text',array(
'twb' => array(
'append' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
)
)
));
$elementCombined = new \Zend\Form\Element('input-text',array(
'twb' => array(
'prepend' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
),
'append' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
)
)
));
echo $this->formRow($elementPrepend);
echo $this->formRow($elementAppend);
echo $this->formRow($elementCombined);
$elementPrepend = new \Zend\Form\Element('input-text',array(
'twb' => array(
'prepend' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'segmented' => true,
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
)
)
));
$elementAppend = new \Zend\Form\Element('input-text',array(
'twb' => array(
'append' => array(
'type' => 'buttons',
'buttons' => array(
'action' => array('options' => array(
'label' => 'Action',
'twb' => array('dropdown' => array(
'segmented' => true,
'actions' => array('Action','Another action','Something else here','-','Separated link')
))
))
)
)
)
));
echo $this->formRow($elementPrepend);
echo $this->formRow($elementAppend);
$form = new \Zend\Form\Form();
$form->add(array(
'name' => 'input-search-append',
'attributes' => array(
'class' => 'search-query input-medium'
),
'options' => array('twb' => array(
'append' => array(
'type' => 'buttons',
'buttons' => array(
'search-submit-append' => array('options' => array('label' => 'Search'),'attributes' => array('type' => 'submit'))
)
)
))
))->add(array(
'name' => 'input-search-prepend',
'attributes' => array(
'class' => 'search-query input-medium'
),
'options' => array('twb' => array(
'prepend' => array(
'type' => 'buttons',
'buttons' => array(
'search-submit-prepend' => array('options' => array('label' => 'Search'),'attributes' => array('type' => 'submit'))
)
)
))
));
echo $this->form($form,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_SEARCH);
$form = new \Zend\Form\Form();
$form->add(array(
'name' => 'button-submit',
'type' => 'button',
'attributes' => array(
'type' => 'submit',
'class' => 'btn-primary'
),
'options' => array(
'label' => 'Save changes',
'twb' => array('formAction' => true)
)
))->add(array(
'name' => 'button-cancel',
'type' => 'button',
'options' => array(
'label' => 'Cancel',
'twb' => array('formAction' => true)
)
));
echo $this->form($form,null);
$element = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'help-inline' => 'Inline help text'
)
));
echo $this->formRow($element);
$element = new \Zend\Form\Element('input-text',array(
'placeholder' => 'Username',
'twb' => array(
'help-block' => 'A longer block of help text that breaks onto a new line and may extend beyond one line.'
)
));
echo $this->formRow($element);
$element = new \Zend\Form\Element('input-text',array(
'twb' => array(
'help-inline' => 'Something may have gone wrong',
'state' => 'warning'
),
'label' => 'Input with warning'
));
echo $this->formRow($element,null,null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL);
$element = new \Zend\Form\Element('input-text',array(
'twb' => array(
'help-inline' => 'Please correct the error',
'state' => 'error'
),
'label' => 'Input with error'
));
$this->formRow($element,null,null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL);
$element = new \Zend\Form\Element('input-text',array(
'twb' => array(
'help-inline' => 'Username is taken',
'state' => 'info'
),
'label' => 'Input with info'
));
echo $this->formRow($element,null,null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL);
$element = new \Zend\Form\Element('input-text',array(
'twb' => array(
'help-inline' => 'Woohoo!',
'state' => 'success'
),
'label' => 'Input with success'
));
echo $this->formRow($element,null,null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL);
$oButton = new \Zend\Form\Element\Button('button-default',array(
'label' => 'Default'
));
echo $this->formButton($oButton);
$oButton = new \Zend\Form\Element\Button('button-primary',array(
'label' => 'Primary'
));
$oButton->setAttribute('class','btn-primary');
echo $this->formButton($oButton);
$oButtonIcon = new \Zend\Form\Element\Button('button-icon',array(
'label' => '',
'twb' => array('icon' => 'icon-star')
));
$oButtonIconLabel = new \Zend\Form\Element\Button('button-icon-label',array(
'label' => 'Star',
'twb' => array('icon' => 'icon-star')
));
echo $this->formButton($oButtonIcon);
echo $this->formButton($oButtonIconLabel);
$oButton = new \Zend\Form\Element\Button('dropdown',array(
'label' => 'Action',
'twb' => array(
'dropdown' => array(
'actions' => array('Action','Another action','Something else here','-','Separated link')
)
)
));
$this->formButton($oButton);
$oButton = new \Zend\Form\Element\Button('button-icon-label-segmented-dropdown',array(
'label' => 'User',
'twb' => array(
'icon' => 'icon-user icon-white',
'dropdown' => array(
'segmented' => true,
'actions' => array(
'edit' => array('label' => 'Edit', 'icon' => 'icon-pencil'),
'delete' => array('label' => 'Belete', 'icon' => 'icon-trash'),
'Ban' => array('label' => 'Ban', 'icon' => 'icon-ban-circle'),
'-',
'Make admin'
)
)
)
));
$oButton->setAttribute('class','btn-primary');
$this->formButton($oButton);
$dropup = new \Zend\Form\Element\Button('segmented-dropup',array(
'label' => 'Dropup',
'twb' => array(
'dropup' => array(
'segmented' => true,
'actions' => array('Action','Another action','Something else here','-','Separated link')
)
)
));
$dropupRight = new \Zend\Form\Element\Button('segmented-right-dropup',array(
'label' => 'Right dropup',
'twb' => array(
'dropup' => array(
'segmented' => true,
'pull' => 'right',
'actions' => array('Action','Another action','Something else here','-','Separated link')
)
)
));
$this->formButton($dropup);
$this->formButton($dropupRight);
Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
echo $this->alert('Test message');
echo $this->alert(
'<h4>Warning!</h4><p>Best check yo self, you\'re not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>',
'block-alert'
);
echo $this->alert(
'<strong>Oh snap!</strong> Change a few things up and try submitting again.',
'alert-error'
);
echo $this->alert(
'<strong>Well done!</strong> You successfully read this important alert message.',
'alert-success'
);
echo $this->alert(
'<strong>Heads up!</strong> This alert needs your attention, but it\'s not super important.',
'alert-info'
);
echo $this->alert('Test message',null,false);