ZenMagick 0.9.8


org.zenmagick.store.mvc.tools.ZMToolboxForm
\store\mvc\tools\ZMToolboxForm.php at line 34

Class ZMToolboxForm

ZMObject
└─ZMToolboxTool
└─ZMToolboxForm

public class ZMToolboxForm
extends ZMToolboxTool

Form related functions.

Author:
DerManoMann
Version:
$Id: ZMToolboxForm.php 2703 2009-12-08 03:35:10Z dermanomann $

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

addProduct(int productId, int quantity, array attr, boolean echo)

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, boolean echo)

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, boolean echo)

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

string

hiddenList(string name, array values, boolean echo)

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

string

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

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, boolean echo)

Create a HTML form tag.

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

Method Detail

\store\mvc\tools\ZMToolboxForm.php at line 159

addProduct

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

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.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A HTML form to add the given productId to the shopping cart.

\store\mvc\tools\ZMToolboxForm.php at line 230

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.

\store\mvc\tools\ZMToolboxForm.php at line 203

fieldLength

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

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.
echo - If true, the attributes will be echo'ed as well as returned.
Returns:
The attributes.

\store\mvc\tools\ZMToolboxForm.php at line 315

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.

\store\mvc\tools\ZMToolboxForm.php at line 178

hiddenCartFields

public string hiddenCartFields(ZMShoppingCartItem item, boolean echo)

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

Parameters:
item - The shopping cart item.
echo - If true, the HTML will be echo'ed as well as returned.
Returns:
HTML form to add a given productId to the shopping cart.

\store\mvc\tools\ZMToolboxForm.php at line 299

hiddenList

public string hiddenList(string name, array values, boolean echo)

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

Parameters:
name - The common name.
values - List of values.
echo - If true, the HTML will be echo'ed as well as returned.
Returns:
HTML formatted input fields of type hidden.

\store\mvc\tools\ZMToolboxForm.php at line 262

idpSelect

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

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.
echo - If true, the HTML will be echo'ed as well as returned.
Returns:
Complete HTML <select> tag.

\store\mvc\tools\ZMToolboxForm.php at line 42

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).

\store\mvc\tools\ZMToolboxForm.php at line 80

open

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

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.
echo - If true, the URI will be echo'ed as well as returned.
Returns:
A HTML form tag plus optional hidden form fields.

ZenMagick 0.9.8