ZenMagick 0.9.10


zenmagick.store.shared.mvc.tools\ZMToolboxForm
mvc\toolbox\ZMToolboxForm.php at line 30

Class ZMToolboxForm

ZMObject
└─ZMToolboxTool
└─ZMToolboxForm

public class ZMToolboxForm
extends ZMToolboxTool

Form related functions.

Author:
DerManoMann

Fields inherited from org.zenmagick.mvc.toolbox\ZMToolboxTool
request_, toolbox_
Fields inherited from org.zenmagick.core\ZMObject
properties_
Method Summary
string

addProduct(int productId, int quantity, array attr)

Convenience function to open a form to add a given product to the shopping cart.

void

checked(boolean setting, boolean value, boolean default)

Makes a checkbox or radio button checked.

string

fieldLength(string table, string col, int max)

Create size and maxlength attributes for input fields.

void

hidden(mixed data)

Create hidden elements from the given map or query args.

string

hiddenCartFields(ZMShoppingCartItem item)

Create all required hidden form fields for a given shoppin cart item.

string

hiddenList(string name, array values)

Create a group of hidden form fields with a common name (ie.

string

idpSelect(string name, array list, string selectedId, array attr)

Create a id/name pair based select box.

void

insertJSValidation(string id)

Convenience method that will generate the JavaScript validation rules and include the generic validation code.

string

open(string page, string params, boolean secure, array attr)

Create a HTML form tag.

Methods inherited from org.zenmagick.mvc.toolbox\ZMToolboxTool
__construct, getRequest, getToolbox, setRequest, setToolbox
Methods inherited from org.zenmagick.core\ZMObject
__construct, attachMethod, get, getAttachedMethods, getProperties, getPropertyNames, set, singleton

Method Detail

mvc\toolbox\ZMToolboxForm.php at line 153

addProduct

public string addProduct(int productId, int quantity, array attr)

Convenience function to open a form to add a given product to the shopping cart.

The calling page is responsible for adding a submit button and a closing <form> tag.

Parameters:
productId - The product (id) to add.
quantity - Optional quantity; default to 0 which means that the card_quantity field will not be added
attr - Optional HTML attribute map; default is an empty array.
Returns:
A HTML form to add the given productId to the shopping cart.

mvc\toolbox\ZMToolboxForm.php at line 220

checked

public void checked(boolean setting, boolean value, boolean default)

Makes a checkbox or radio button checked.

Parameters:
setting - The actual value.
value - The value for this radio button; default is true.
default - The default state; default is false.

mvc\toolbox\ZMToolboxForm.php at line 194

fieldLength

public string fieldLength(string table, string col, int max)

Create size and maxlength attributes for input fields.

Parameters:
table - The table name.
col - The column name.
max - The size attribute; default is 40; use 0 to prevent a size attribute.
Returns:
The attributes.

mvc\toolbox\ZMToolboxForm.php at line 301

hidden

public void hidden(mixed data)

Create hidden elements from the given map or query args.

Parameters:
data - Either a map or query arg style string.

mvc\toolbox\ZMToolboxForm.php at line 171

hiddenCartFields

public string hiddenCartFields(ZMShoppingCartItem item)

Create all required hidden form fields for a given shoppin cart item.

Parameters:
item - The shopping cart item.
Returns:
HTML form to add a given productId to the shopping cart.

mvc\toolbox\ZMToolboxForm.php at line 286

hiddenList

public string hiddenList(string name, array values)

Create a group of hidden form fields with a common name (ie. someId[]).

Parameters:
name - The common name.
values - List of values.
Returns:
HTML formatted input fields of type hidden.

mvc\toolbox\ZMToolboxForm.php at line 251

idpSelect

public string idpSelect(string name, array list, string selectedId, array attr)

Create a id/name pair based select box.

Helper function that can create a HTML <select> tag from any array that contains class instances that provide getId() and getName() getter methods.

Please note that there are two special attribute keys that can be used to control the method names used to populate option value and text.

Default attributes are:

Parameters:
name - The name.
list - A list of options.
attr - Optional HTML attribute map; default is null.
selectedId - Value of option to select; default is null.
Returns:
Complete HTML <select> tag.

mvc\toolbox\ZMToolboxForm.php at line 38

insertJSValidation

public void insertJSValidation(string id)

Convenience method that will generate the JavaScript validation rules and include the generic validation code.

Parameters:
id - The id of the form to validate (the ZMRuleSet name).

mvc\toolbox\ZMToolboxForm.php at line 75

open

public string open(string page, string params, boolean secure, array attr)

Create a HTML form tag.

The mother of all form methods.

Parameter ($params) will be added as hidden form fields, wrapped in a <div> tag.

The default method value is post.

This method will also add JavaScript validation code if the following conditions are met:

  1. The setting isAutoJSValidation is set to true
  2. A form id has been provided via $attr, as that will be used to lookup the validation rules.

Default attributes are:

To remove any default attributes, set a value of null in the $attr parameter.

All attribute names are expected in lower case.

Parameters:
page - The action page name.
params - Query string style parameter.
secure - Flag indicating whether to create a secure or non secure action URL; default is true.
attr - Optional HTML attribute map; default is null.
Returns:
A HTML form tag plus optional hidden form fields.

ZenMagick 0.9.10