HTML_QuickForm_Renderer_Array

HTML_QuickForm_Renderer_Array

HTML_QuickForm_Renderer_Array -- Array representation of the form

Description

This renderer does not output anything itself, it returns the form structure as an array. This array can later be used for generating the output. A usage example is available for this renderer and Smarty template engine, look in docs/renderers directory.

The form array structure is the following:
array(
  'frozen'           => 'whether the form is frozen',
  'javascript'       => 'javascript for client-side validation',
  'attributes'       => 'attributes for <form> tag',
  'requirednote      => 'note about the required elements',
  // if we set the option to collect hidden elements
  'hidden'           => 'collected html of all hidden elements',
  // if there were some validation errors:
  'errors' => array(
    '1st element name' => 'Error for the 1st element',
    ...
    'nth element name' => 'Error for the nth element'
  ),
  // if there are no headers in the form:
  'elements' => array(
    element_1,
    ...
    element_N
  )
  // if there are headers in the form:
  'sections' => array(
    array(
      'header'   => 'Header text for the first header',
      'name'     => 'Name of the first header',
      'elements' => array(
         element_1,
         ...
         element_K1
      )
    ),
    ...
    array(
      'header'   => 'Header text for the Mth header',
      'elements' => array(
         element_1,
         ...
         element_KM
      )
    )
  )
);
where element_i is an array of the form:
array(
  'name'      => 'element name',
  'value'     => 'element value',
  'type'      => 'type of the element',
  'frozen'    => 'whether element is frozen',
  'label'     => 'label for the element',
  'required'  => 'whether element is required',
  'error'     => 'error associated with the element',
  'style'     => 'some information about element style (e.g. for Smarty)',
  // if element is not a group
  'html'      => 'HTML for the element'
  // if element is a group
  'separator' => 'separator for group elements',
  'elements'  => array(
    element_1,
    ...
    element_N
  )
);

Tip: HTML_QuickForm::toArray() method uses the Array renderer internally.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.