.

WidgetInput Class Reference
[View]

Create an input widget (not necessarily an input element). More...

Inheritance diagram for WidgetInput:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct ($name, $label, $value, $type, $params)
  Cosntructor.
  render ($policy=self::NONE)
  Render content.

Static Public Member Functions

static  output ($name, $label, $value= '', $type=self::TEXT, $params=array(), $policy=self::NONE)

Public Attributes

  $label
  $name
  $params
  $type
  $value
const  CHECKBOX = 'checkbox'
const  DATE = 'date'
const  FILE = 'file'
const  FORCE_CHECKBOXES = 512
  For multiselect: Use checkboxes, even if number of items > 5.
const  FORCE_SELECT_BOX = 1024
  For multiselect: Use select box, even if number of items <= 5.
const  HIDDEN = 'hidden'
const  MULTISELECT = 'multiselect'
const  NO_BREAK = 128
  Do not add breaks after input element.
const  NO_LABEL = 2048
  Do not use a label at all.
const  PASSWORD = 'password'
const  RADIO = 'radio'
const  SELECT = 'select'
const  SUBMIT = 'submit'
const  TEXT = 'text'
const  TEXTAREA = 'textarea'
const  WRAP_LABEL = 256
  Wrap label around inputs, instead putting it before them.

Detailed Description

Create an input widget (not necessarily an input element).

Requires.

  • name: input name (and id, if id is not set)
  • type: hidden, text, select, checkbox (defaults to text)

Optional param array has different members according to type

Accepts:

  • id (optional): id of element, defaults to name
  • value (optional): Default value for input. If this is an array, [$name] is extracted

If type is not hidden, the following is supported

  • label (optional): Label text
  • item (optional): If provided item is checked if field can be edited
  • notes (optional): If larger than 0, n stars (*) are added. E.g. notes:2 adds 2 stars. Needs label to be set

If type is text, the following is supported:

  • size (optional): For text fields

If type is select, multi select or radio buttons, the following is supported:

  • options: Array of options. Options are key => value pair. If value itself is an array, all its values will be put into an <optgroup>
  • value (optional): The select option (key)
  • nodefault (optional): If true the first option is NOT preselected, instead "Please Choose" is show

If type is file:

  • size (optional): For text fields
  • accepts: Mime types to accept

Note that for file type input boxes to work in PHP, the form must have the attribute enctype="multipart/form-data"!

Author:
Gerd Riesselmann

Definition at line 43 of file input.widget.php.


Constructor & Destructor Documentation

WidgetInput::__construct ( name,
label,
value,
type,
params  
)

Cosntructor.

Parameters:
string  $name
string  $type
array  $params

Definition at line 96 of file input.widget.php.

00096                                                                            {
00097                 $this->name = $name;
00098                 $this->label = $label;
00099                 $this->type = $type;
00100                 $this->value = is_array($value) ? Arr::get_item_recursive($value, $name, '') : $value;
00101                 $this->params = Arr::force($params, false);
00102         }

Member Function Documentation

static WidgetInput::output ( name,
label,
value = '',
type = self::TEXT,
params = array(),
policy = self::NONE  
) [static]

Definition at line 84 of file input.widget.php.

00084                                                                                                                            {
00085                 $widget = new WidgetInput($name, $label, $value, $type, $params);
00086                 return $widget->render($policy);
00087         }
WidgetInput::render ( policy = self::NONE  ) 

Render content.

Parameters:
int  $policy
Returns:
string

Implements IRenderer.

Definition at line 110 of file input.widget.php.

00110                                                    {
00111                 Load::classes_in_directory('view/widgets/input', array('base', $this->type), 'input.widget', true);
00112                 $cls = 'InputWidget' . Load::filename_to_classname($this->type);
00113                 if (class_exists($cls)) {
00114                         $delegate = new $cls($this->name, $this->label, $this->value, $this->params);
00115                         return $delegate->render($policy);
00116                 }       
00117                 else {
00118                         throw new Exception('input: unknown type "' . $this->type . '"');
00119                 }       
00120         }

Member Data Documentation

WidgetInput::$label

Definition at line 45 of file input.widget.php.

WidgetInput::$name

Definition at line 44 of file input.widget.php.

WidgetInput::$params

Definition at line 48 of file input.widget.php.

WidgetInput::$type

Definition at line 46 of file input.widget.php.

WidgetInput::$value

Definition at line 47 of file input.widget.php.

const WidgetInput::CHECKBOX = 'checkbox'

Definition at line 77 of file input.widget.php.

const WidgetInput::DATE = 'date'

Definition at line 82 of file input.widget.php.

const WidgetInput::FILE = 'file'

Definition at line 81 of file input.widget.php.

For multiselect: Use checkboxes, even if number of items > 5.

Definition at line 61 of file input.widget.php.

For multiselect: Use select box, even if number of items <= 5.

Definition at line 65 of file input.widget.php.

const WidgetInput::HIDDEN = 'hidden'

Definition at line 76 of file input.widget.php.

const WidgetInput::MULTISELECT = 'multiselect'

Definition at line 75 of file input.widget.php.

const WidgetInput::NO_BREAK = 128

Do not add breaks after input element.

Definition at line 53 of file input.widget.php.

const WidgetInput::NO_LABEL = 2048

Do not use a label at all.

Definition at line 69 of file input.widget.php.

const WidgetInput::PASSWORD = 'password'

Definition at line 73 of file input.widget.php.

const WidgetInput::RADIO = 'radio'

Definition at line 80 of file input.widget.php.

const WidgetInput::SELECT = 'select'

Definition at line 74 of file input.widget.php.

const WidgetInput::SUBMIT = 'submit'

Definition at line 79 of file input.widget.php.

const WidgetInput::TEXT = 'text'

Definition at line 72 of file input.widget.php.

const WidgetInput::TEXTAREA = 'textarea'

Definition at line 78 of file input.widget.php.

Wrap label around inputs, instead putting it before them.

Definition at line 57 of file input.widget.php.


The documentation for this class was generated from the following file: