``. This property is useful if your form uses
JavaScript to show and hide fields which a visually-impaired user would
not otherwise notice. Setting this property automatically adds the
paragraph class ``accessible-text``.
For example, the following Pancake form field:
.. code-block:: php
= $form->text('event_contact', array(
'accessible_text' => 'This field is only necessary if it\'s
different from the primary contact.'
)) ?>
results in the following HTML output:
.. code-block:: html
Event Contact
This field is only necessary if it's different from the primary contact.
.. _option-after:
``after``
---------
.. attribute:: after
Arbitrary string value that is displayed after the field-form input.
.. _option-before:
``before``
----------
.. attribute:: before
Arbitrary string value that is displayed before the ````.
.. _option-container:
``container``
-------------
.. attribute:: container
HTML tag that encompasses the entire form field. Do not include opening
and closing angle brackets. Defaults to ``p``.
.. note::
This property is used internally by :ref:`list fields `
to change the default ``p`` to a ``div``, which is more suitable for a
group of form fields that each have their own container element.
.. _option-help_text:
``help_text``
-------------
.. attribute:: help_text
Instructional text which is placed within the ````, but after the
label text. Setting this property automatically adds the paragraph class
``help-text``.
.. image:: _images/option-help-text.png
.. _option-label:
``label``
---------
.. attribute:: label
Explicit label text. The label text is otherwise generated based on the
form field's name.
.. _option-label_element:
``label_element``
-----------------
.. attribute:: label_element
HTML tag that encompasses the label text. If the value is not ``label``,
the ``for`` attribute will be removed. Do not include opening and closing
brackets. Defaults to ``label``.
.. note::
This property is used internally by :ref:`list fields `
to change the default ``label`` to an ``h3``, which is more suitable
for a group of form fields that each have their own ````.
.. _option-label_first:
``label_first``
---------------
.. attribute:: label_first
Whether or not the ```` should precede the form-field input.
If ``false``, the ```` succeeds the form-field input.
Defaults to ``true``.
.. note::
This property is used internally by :ref:`checkboxes `
to place the ```` after the checkbox.
.. _option-label_short:
``label_short``
---------------
.. attribute:: label_short
Truncated label text which is used in validation messages. This property
is useful for essay questions which may be abnormally long in the
top-of-the-form validation message.
.. _option-paragraph:
``paragraph``
-------------
.. attribute:: paragraph
Whether or not to encompass the field in a container element, i.e.
a paragraph. Defaults to ``true``.
.. _option-paragraph_classes:
``paragraph_classes``
---------------------
.. attribute:: paragraph_classes
Pancake automatically adds classes to your form-field container which
correspond to the type of form field and to the form field's other
options. Additionally, any form field with validation errors will
automatically receive the class ``error``. You can further add custom
classes to the form-field container using this property.
See :doc:`/references/form-fields` for details about automatically assigned
paragraph classes based on the form-field type.
.. _option-required:
``required``
------------
.. attribute:: required
Whether or not the field is required. If ``false``, the field will be
marked as optional in the ````. Optional fields will automatically
receive the paragraph class ``optional``. Defaults to ``true``.
This message will be hidden if ``required`` is set to ``false``:
.. image:: _images/option-required.png
.. _option-required-if:
``required_if``
---------------
.. attribute:: required_if
This option allows you to set the requirement of a field based on the value
of another field. The property value should be an array wherein the first
entry is the name of the dependent field and the second entry is the target
value.
.. code-block:: php
= $form->text('foo', array(
'required_if' => array('conditional', 'value')
)) ?>
.. _option-show_errors:
``show_errors``
---------------
.. attribute:: show_errors
Whether or not to show the validation errors in the field's ````.
Defaults to ``true``.
.. _option-show_field:
``show_field``
--------------
.. attribute:: show_field
Whether or not to show the form-field input element. Defaults to ``true``.
.. _option-show_if_optional:
``show_if_optional``
--------------------
.. attribute:: show_if_optional
Whether or not to show if the field is optional in the ````.
Defaults to ``true``.
.. _option-show_label:
``show_label``
--------------
.. attribute:: show_label
Whether or not to show the ````. Defaults to ``true``.
.. _option-validation:
``validation``
--------------
.. attribute:: validation
Validators to apply to the form field. See :ref:`validation` for more
information about field validation.