What are the settings/options available when building a form structure?
Contents |
defaults
These are all the current settings/options when building a form structure, as well as their default settings...
$defaults = array( 'type' => $this->params['action'], 'data' => false, 'settings' => array( 'return' => false, 'actions' => true, 'header' => '', 'form_top' => true, 'tabindex' => 0, 'form_inputs' => true, 'form_bottom' => true, 'name_prefix' => NULL, 'pagination' => true, 'column_names' => array(), 'stretch' => true, 'all_fields' => false, 'add_fields' => false, 'del_fields' => false, 'tree' => array(), 'data_miss_warn'=>true, 'paste_disabled_fields' => array() ), 'links' => array( 'top' => false, 'index' => array(), 'bottom' => array(), 'tree' => array(), 'checklist' => array(), 'radiolist' => array(), 'ajax' => array( 'top' => false, 'index' => array(), 'bottom' => array() ) ), 'override' => array(), 'dropdown_options' => array(), 'extras' => array() );
type
The type of form structure the helper should build. The currently recognized values are add, edit, addgrid, editgrid, detail, index, search and tree". Although deprecated, datagrid works as an addgrid.
These types produce 3 kind of displays. Add, edit, detail and search produce display where there is one value/input for each field. Addgrid, editgrid ans table procude a display where there can be multiple values/inputs for each field. They are presented as a table where each line represent a record. Finally, tree is a kind of it's own. It produces a tree view that can contain different structures, one for each data types.
data
An array of model.field data to populate the form structure with. Please note, this is only used for display structures, like "index" and "detail", and will not work for edit or add forms.
settings
Control what portions of the form structure is shown and how it is shown. Particularly useful when "stacking" multiple forms to make one large form
actions
True to show the action bar, false to not render it
add_fields
Used in datagrid form structures. If true, adds an "add another" link after form to allow another row to be appended
all_fields
False acts on structures datatable settings, true ignores them and displays all fields in a form regardless
columns_names
An ordered array of the columns keys to use. These keys will be displayed at the top of the form and they will be used to parse the data array. When the columns_names parameter is defined, the data array need to be formated using it. Eg.: Say you have the following keys: September and October. Then your data array will have values in $data[model][field]["September"] and $data[model][field]["October"]. This behaviour is useful for reports. Note: Only works for index views.
data_miss_warn
By default, when debug mode is on, a warning is printed when a value cannot be found for a structure field. Setting data_miss_warn to false will not trigger the warning message.
del_fields
Used in datagrid form structures. If true, add a "remove" link after each row, to allow it to be removed from the form
form_bottom
True to render the closing form tag and the submit button, false to not render either of those tags
form_inputs
If true, use inputs when supposed to, if false use static display values regardless
form_top
True to render the opening form tag, false to not render that tag
header
If you want to print a header to your structure, you may use the header setting. When you are printing multiple structures within the same view, this setting is useful in helping to distinguish them.
Pass and array into this option to set the header at the top of the structure, using the "title" key for the title and the "description" key for the title. The two values should be untranslated aliases, the structures helper will call the translation function on both values.
name_prefix
Defines a prefix for the input names. Usefull for add/edit form where the same structure is printed many times.
pagination
True to force pagination on an index view, false to display all results.
paste_disabled_fields
Used in addgrids and editgrids, an array of fields (model.field) on which pasting will be blocked. It can be useful to prevent pasting on fields where you generate values (eg.: label, barcode) to prevent the paste operation to overwrite them when the user wants to copy/paste the date. An icon is prepended to the field to let the user know that the said field will not be affected by pasting.
stretch
True to have the structure take the full page width.
tabindex
An integer value added to all tabindex values in all input fields. Since stacked forms are unaware of each other, use this to force all tabindexes to be in the correct order. Defaults to 0.
tree
Indicates multiple atim_structures passed to this class, and which ones to use for which model in each tree row. Since the tree structure usually comes with ajax calls to display elements details in the right half of the screen, you will need to link a javascript file to your view. Just before doing that, you need to set the translation for the loading string. Basically, you can copy paste the following code to the bottom of your view.
?> <script> var loadingStr = "<?php echo(__("loading", null)); ?>"; </script> <?php echo $javascript->link('treeViewControl')."\n"; ?>
return
False echos structure, true returns it as string
links
ajax
Change any of the above links (top, index, and bottom) into ajax calls instead
bottom
An array of links, to appear in the action bar below the form structure
checklist
Keys are checkbox names (model.field) and values are checkbox values
index
An array of links, to appear for each row of a table view
radiolist
Keys are radio button names (model.field) and values are radio button values
top
A single URL, if present, will turn structure into a form and this url is used as the form action attribute.
tree
An array of links, to appear for each element of a tree structure. Here is an example
'tree'=>array(
'SampleMaster' => array(
'detail' => array(
'link' => '/inventorymanagement/sample_masters/detail/%%SampleMaster.collection_id%%/...',
'icon' => 'lungs'
)
),
'AliquotMaster' => array(
'detail' => array(
'link' => '/inventorymanagement/aliquot_masters/detail/%%AliquotMaster.collection_id%%/...',
'icon' => 'aliquot')
)
),
The example above would display samples and aliquots in a tree view. The only associated link for both of these is detail. For each of these, the link to the detail page is defined as well as a reference to the icon to represent it.
override
A model.field data array, used to override the default values of a display or input field.
dropdown_options
A model.field data array that changes the options available within a dropdown. The dropdown array must be of the same for as the ones returned by dropdown generating functions. So array("value 1" => "display 1", "value n", "display n", ...).
extras
An array of raw HTML, each key being a column to attach to the form.