Skip to content
Derek Jones edited this page Jul 5, 2012 · 9 revisions

Category:Libraries::SuperModel

The following are the pre-defined types and controls defined. See SuperModel::CustomTypes for information on creating custom types/controls. See SuperModel::Fields for values that are applicable to all field types.

Any unrecoginized types will be defaulted to text.

header

Defines a fieldset tag. Takes only label as a parameter.

If a

tag has already been opened, it is closed first. SuperModel has special code to detect when a is used, and will automatically close it at the end of the form.

Example:

  'details' => array(
    'label' => 'Account Details',
  ),

Sample output:

<fieldset>
<legend id="user_model_details">Account Details</legend>

text

A basic text box.

Basic parameters: label, rules (see SuperMode::Types::Rules),

Other parameters:

$size is the HTML size= parameter. Optimally, this would be specified with CSS (so presentation logic wouldn't need to be here) but since (1) not all browsers support all CSS options, and (2) you are not forced to use CSS with SuperModel, it is specified here.

If a rule for max_length is specified, then the html maxlength= tag automatically gets this value. This is a bit of a hack, but simplifies fields definition.

Example:

  'username' => array( 
     'label' => 'User name',
     'type' => 'text',
     'size' => 25,
     'rules' => 'required|max_length[25]',
  ),

Outputs:

<div id="user_model_username_container" class="form_field_container">
    <div class="form_field_label"><label for="user_model_username">User name</label></div>
    <div class="form_field_control">&lt;input name="name" value="" maxlength="25" size="15" id="user_model_username" type="text"&gt;</div>
    <div class="form_field_footer"></div>
</div>

password

Exactly the same as text, but outputs as an HTML password input (characters are hidden).

textarea

A basic text area.

Basic parameters: label, rules (see SuperMode::Types::Rules),

Other parameters:

$rows and $cols specify the HTML size of the box.

checkbox

not done yet

radio

not done yet

select

submit

A submit button to submit the form. By default this value is not stored, but this can be overridden using the $store boolean option.

By default, no label will be used unless you specify one.

$value is the text of the button.

static

Simply outputs the raw value as loaded from the database.

Parameters: label

hidden

A hidden field passed along with the form.

calculated

in progress

So far, allows:

  'fullname' => array(
    'type' => 'calculated',
    'label' => 'Full Name', 
    'query' => 'CONCAT(first_name, " ", last_name)',
  ),

This is useful for lists (see SuperModel::API::GetList).

serverside

A field with a value stored in the database, but never presented on the client side. Good for adding extra fields to a record, such as their user ID. Using 'serverside' allows the value to be added in the controller, and stored into the database, but it is impossible for the user to modify or even see the value from the client side. If done with a hidden field, they could forge a form and submit their own modified value.

See SuperModel::API for information on how to set this value.

content

Static content. Useful for providing help text in the form, or anything else that should show up along with the form controls.

Parameters: label

$value represents the text to output.

Clone this wiki locally