ZenMagick 0.9.6


org.zenmagick.rp.toolbox.defaults.ZMToolboxForm

Class ZMToolboxForm

ZMObject
|
+--ZMToolboxForm

public class ZMToolboxForm
extends ZMObject

Form related functions.

Author:
DerManoMann
Version:
$Id: ZMToolboxForm.php 1966 2009-02-14 10:52:50Z dermanomann $

Fields inherited from org.zenmagick.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(mixed setting, mixed 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.

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.

string

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

Create a HTML form tag.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Method Detail

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.

checked

public void checked(mixed setting, mixed 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.

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.

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.

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.

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.

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