-
Notifications
You must be signed in to change notification settings - Fork 11
View helpers
stephencoe edited this page Aug 3, 2013
·
13 revisions
There are a number of view helpers available to you. To make life easier, I've documented their syntax, and uses for you.
<?php
// Get the bootstrap files. (before outputting headscript/headlink!)
$this->sxBootstrap();
?>
This assumes that you already have a zend\Form
assigned to your view. If you haven't, or don't know how to work with forms yet, take a look at the Zend\form reference guide.
<?php
// render a whole form
echo $this->sxbForm($this->form);
?>
<?php
// render element by element
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
echo $this->sxbFormElement($form->get('element'));
//render a form collection, useful for rendering fieldsets
echo $this->formCollection()->setDefaultElementHelper('\SxBootstrap\View\Helper\Bootstrap\FormElement')->render($form->get('fieldset'));
echo $this->form()->closeTag();
?>
<?php
echo $this->sxbAlert('This is an alert');
// additional parameters: block level and class
echo $this->sxbAlert('This is an alert', true, 'alert-warning');
// explicit usage
// explicit types: info, error, success, warning
echo $this->sxbAlert()->warning('This is an alert');
// explicit additional parameters: block level
echo $this->sxbAlert()->warning('This is an alert');
?>
<?php
echo $this->sxbBadge('This is a badge');
// additional parameters: class
echo $this->sxbBadge('This is a badge', 'badge-info');
// explicit usage
// explicit types: info, important, inverse, success, warning
echo $this->sxbBadge()->info('This is a badge');
?>
<?php
echo $this->sxbLabel('This is a label')
// additional parameters: class
echo $this->sxbLabel('This is a label', 'label-info');
// explicit usage
// explicit types: info, important, inverse, success, warning
echo $this->sxbLabel()->info('This is a label');
?>
<?php
echo $this->sxbButton('This is a button')
// additional parameters: class, data-type, data-text
// additional data-types: loading|toggle
echo $this->sxbButton('test', 'btn-info', 'toggle', 'Loading..');
// explicit usage
// explicit types: info, primary, success, warning, danger, inverse, link
echo $this->sxbButton()->info('This is a button');
?>