\Dewdrop\View\HelperBootstrapForm

Render an HTML form using Bootstrap classes and markup. Note that this view helper can also render a \Dewdrop\Fields\GroupedFields object in a tab view.

This class provides:

  • A reference to the view that originally instantiated the helper.
  • The ability to easily render partial view scripts.
  • The ability to manage methods implementing the 3 Dewdrop view helper argument styles (i.e. Field, explicit and array).

Summary

Methods
Properties
Constants
__construct()
partial()
direct()
directWithArgs()
open()
close()
renderContent()
renderGroupedFields()
renderFields()
renderFieldsInTableRow()
renderFieldContent()
renderFormGroupOpenTag()
renderLabel()
renderLabelContent()
renderRequiredFlag()
renderMessages()
renderSubmitButton()
No public properties found
No constants found
delegateIfArgsProvided()
delegateByArgs()
checkRequired()
getHelperName()
ensurePresent()
ensureArray()
controlRequiresLabel()
$view
N/A
No private methods found
No private properties found
N/A

Properties

$view

$view : \Dewdrop\View\View

The view that instantiated this helper.

Type

\Dewdrop\View\View

Methods

__construct()

__construct(\Dewdrop\View\View  $view) 

Create helper, accepting a reference to the related view object

Parameters

\Dewdrop\View\View $view

partial()

partial(string  $name, array  $data) : string

Render a partial view script.

Generally, your helper should render HTML with partial view scripts rather than generating the markup in the helper class directly. This makes it easier for frontend developers to make modifications to the HTML.

The $data parameter should contain key-value pairs for each variable you'd like available in your partial view.

Parameters

string $name
array $data

Returns

string —

The rendered output

direct()

direct() : mixed

If the user supplies no arguments, we return immediately, assuming that they want to call other methods on this helper directly. Otherwise, we pass execution along to the directWithArgs() method so that the arguments can be validated.

Returns

mixed

directWithArgs()

directWithArgs(\Dewdrop\Fields  $fields, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer = null) : string

If the direct method was called with arguments, it delegates to this method. When a user supplies a \Dewdrop\Fields object, a \Zend\InputFilter\InputFilter object and an optional TableCell field helper as a renderer, the view helper can render the entire form in a single step.

Parameters

\Dewdrop\Fields $fields
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer

Returns

string

open()

open(string  $action = '', string  $method = 'POST', string  $id = '', string  $class = '') : string

Open the form table, optionally supplying a method and action attribute.

Parameters

string $action
string $method
string $id
string $class

Returns

string

close()

close() : string

Close the form tag.

Returns

string

renderContent()

renderContent(\Dewdrop\Fields  $fields, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer) : mixed

Only render groups in a tab view if there is more than 1 group because when there is only 1 group, that means only the default "ungrouped" or "other" set is present.

Parameters

\Dewdrop\Fields $fields
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer

Returns

mixed

renderGroupedFields()

renderGroupedFields(\Dewdrop\Fields\GroupedFields  $groupedFields, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer) : string

Render a GroupedFields object using a Bootstrap tab view.

Parameters

\Dewdrop\Fields\GroupedFields $groupedFields
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer

Returns

string

renderFields()

renderFields(\Dewdrop\Fields  $fields, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer, integer  $fieldPosition) : string

Render the supplied set of ungrouped fields, using the supplied InputFilter to get validation messages, etc.

Parameters

\Dewdrop\Fields $fields
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer
integer $fieldPosition

Returns

string

renderFieldsInTableRow()

renderFieldsInTableRow(\Dewdrop\Fields  $fields, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer) 

Parameters

\Dewdrop\Fields $fields
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer

renderFieldContent()

renderFieldContent(\Dewdrop\Fields\FieldInterface  $field, \Zend\InputFilter\InputFilter  $inputFilter, \Dewdrop\Fields\Helper\EditControl  $renderer,   $position,   $renderLabels = true) 

Parameters

\Dewdrop\Fields\FieldInterface $field
\Zend\InputFilter\InputFilter $inputFilter
\Dewdrop\Fields\Helper\EditControl $renderer
$position
$renderLabels

renderFormGroupOpenTag()

renderFormGroupOpenTag() : string

This particular bit of the markup is separated out so that sub-classes could easily apply classes to it, primarily to take advantage of Bootstrap's responsive grids. Note that the returned string should include a sprintf() string placeholder ("%s") so that validation-related classes can be added as well.

Returns

string

renderLabel()

renderLabel(\Dewdrop\Fields\FieldInterface  $field, \Dewdrop\Fields\Helper\EditControl  $renderer, \Zend\InputFilter\Input  $input = null) : string

Render the label for the supplied field, included a "required" flag when appropriate.

Parameters

\Dewdrop\Fields\FieldInterface $field
\Dewdrop\Fields\Helper\EditControl $renderer
\Zend\InputFilter\Input $input

Returns

string

renderLabelContent()

renderLabelContent(\Dewdrop\Fields\FieldInterface  $field, \Dewdrop\Fields\Helper\EditControl  $renderer, \Zend\InputFilter\Input  $input = null) : string

Render the content of a label for the supplied field, included a "required" flag when appropriate.

Parameters

\Dewdrop\Fields\FieldInterface $field
\Dewdrop\Fields\Helper\EditControl $renderer
\Zend\InputFilter\Input $input

Returns

string

renderRequiredFlag()

renderRequiredFlag() : string

Render a "required" flag using Boostrap's glyphicons.

Returns

string

renderMessages()

renderMessages(array  $messages) : string

Render the supplied validation messages using Bootstraps' help-block class.

Parameters

array $messages

Returns

string

renderSubmitButton()

renderSubmitButton(string  $title = 'Save Changes', string  $classes = '', boolean  $disableOnSubmit = true) : string

Render a simple submit button at the footer of the form, with optional classes on that submit button. If the $disableOnSubmit argument is false, the button will not be disabled upon form submission.

Parameters

string $title
string $classes

optional

boolean $disableOnSubmit

Returns

string

delegateIfArgsProvided()

delegateIfArgsProvided(array  $args, string  $method = 'directWithArgs') : $this|string

Useful in cases where you want to just return the helper if the user didn't provide any args to direct(), but want to call a short-cut method if they did.

Parameters

array $args
string $method

Returns

$this|string

delegateByArgs()

delegateByArgs(array  $args, string  $methodPrefix) : mixed

Delegate to one of three methods depending upon the contents of the $args array:

  • If $args[0] is an instance of \Dewdrop\Db\Field, call "{$methodPrefix}Field".
  • If $args[0] is an array, call "{$methodPrefix}Array".
  • Otherwise, call "{$methodPrefix}Explicit".

Parameters

array $args

The arguments to pass the delegated method.

string $methodPrefix

Returns

mixed

checkRequired()

checkRequired(array  $options, array  $required) : \Dewdrop\View\Helper\AbstractHelper

Check that the values in $required are present as keys in $options.

Use this in methods accepting parameters as an array of key-value pairs to ensure that required parameters are present. If one of the required parameters is absent, an exception is thrown.

Parameters

array $options
array $required

Throws

\Dewdrop\Exception

Returns

\Dewdrop\View\Helper\AbstractHelper

getHelperName()

getHelperName() : string

Get the helper name, which is the suffix at the end of the fully qualified class name after the final namespace separator ("\").

Returns

string

ensurePresent()

ensurePresent(array  $options, array  $present) : \Dewdrop\View\Helper\AbstractHelper

Ensure that the values in $present are keys in $options.

If the key is absent from $options, it will be added with a null value. Therefore, this method differs from checkRequired() in that the user must supply a value (even if that value is null) before checkRequired(), but for ensurePresent() the key will simply be added if the user hadn't already specified a value.

Note: Notice that the $options parameter is handled by-reference to allow creation of the missing keys while still allowing chaining to other methods.

Parameters

array $options
array $present

Returns

\Dewdrop\View\Helper\AbstractHelper

ensureArray()

ensureArray(array  $options, array  $isArray) : \Dewdrop\View\Helper\AbstractHelper

Ensure that the values in the $isArray parameter are present in $options as an array.

If the option's current value is null, it will be converted to an array. If the option's current value is not null but also not an array, it will be wrapped in an array. For example, if you had a "classes" option that let the user specify one or more CSS classes, they could use a string to define a single class and this method would wrap that single value in array array to make the handling of the various options simpler and more consistent for the view helper developer.

Note: Notice that the $options parameter is handled by-reference to allow creation of the missing keys while still allowing chaining to other methods.

Parameters

array $options
array $isArray

Returns

\Dewdrop\View\Helper\AbstractHelper

controlRequiresLabel()

controlRequiresLabel(string  $output) : boolean

When a field's rendered control contains its own label and is not a list, we skip the rendering the label in this header. This is meant to skip redundant labels on checkbox controls while still rendering labels for checkbox or radio button lists.

Parameters

string $output

Returns

boolean