Sitellite Application Framework
Class Tree         Index         All Elements

Class: MF_Widget_tie

Source Location: Program_Root/MailForm/Widget/Tie.php

Class Overview

MF_Widget
   |
   --MF_Widget_tie

Tied select widget. Ties the values of one select widget to the actions of another, allowing the option list to change dynamically based on previous choices made in the form.


Author(s)

Version

  • 1.0, 2002-09-26, $Id: Tie.php,v 1.4 2006/09/22 07:49:48 lux Exp $

Copyright

  • Copyright (C) 2001-2003, Simian Systems Inc.

Variables

Methods


Inherited Variables

Inherited Methods

Class: MF_Widget

MF_Widget::MF_Widget()
Constructor Method.
MF_Widget::addRule()
Adds a validation rule to the list of $rules.
MF_Widget::attr()
This is the accessor method for setting and getting the value of
MF_Widget::changeType()
MF_Widget::display()
Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).
MF_Widget::getAttrs()
Returns a list of all of the attributes of this object's HTML tag in a string ready to be concatenated into the actual rendered tag output.
MF_Widget::getValue()
Fetches the actual value for this widget.
MF_Widget::invalid()
Returns a ' class="invalid"' string if the widget's $invalid property is set to true, or an empty string otherwise.
MF_Widget::setDefault()
Sets the default value for the widget.
MF_Widget::setValue()
Sets the *ACTUAL* value for this widget. An optional second parameter can be passed, which is unused here, but can be used in complex widget types to assign parts of a value and piece it together from multiple physical form fields.
MF_Widget::setValues()
Sets the *POSSIBLE* values for this widget. If $value is given, sets $this->value as a hash, otherwise, as a string.
MF_Widget::unsetAttr()
Use this method to remove an attribute from the tag
MF_Widget::validate()
Validates the widget against its set of $rules. Returns false on failure to pass any rule.
MF_Widget::validation()
Sets the validation $rule for this widget. Note: This method is deprecated and only wraps around the addRule() method anyway. Please use addRule() instead, since this method will be removed in a near-future release.

Class Details

[line 95]
Tied select widget. Ties the values of one select widget to the actions of another, allowing the option list to change dynamically based on previous choices made in the form.


1 <?php
2
3 $tied = new MF_Widget_select ('tied');
4 $widget = new MF_Widget_tie ('name');
5 $widget->tie = 'tied';
6
7 $tied->extra = 'onchange="changeOptions (this.form, \'name\', \'tied\'); reLoad ()"';
8
9 // now optional -- called automatically by display()
10 echo $widget->includeJS ();
11
12 $list = array (
13 'one' => array (
14 'a' => 'A',
15 'b' => 'B',
16 ),
17 'two' => array (
18 'c' => 'C',
19 'd' => 'D',
20 ),
21 )
22
23 foreach ($list as $item => $list) {
24 $tied->setValues ($item, ucfirst ($item));
25 $widget->ties[$item] = $list;
26 }
27
28 $widget->validation ('is "foo"');
29 $widget->setValue ('foo');
30 $widget->error_message = 'Oops! This widget is being unruly!';
31
32 ?>

Alternately, via INI settings:


1 [tied]
2
3 type = select
4 setValues = "eval: assoscify (range ('a', 'g'))"
5 extra = "onchange=`changeOptions (this.form, 'name', 'tied'); reLoad ()`"
6
7 [name]
8
9 type = tie
10 setValues = "eval: array ('a' => assocify (array ('a','b','c')), etc.)"
11 tie = tied

Note that the eval options would presumably be replaced with a call to an external function in real-life scenarios.




Tags:

access:  public
version:  1.0, 2002-09-26, $Id: Tie.php,v 1.4 2006/09/22 07:49:48 lux Exp $
license:  http://www.sitellite.org/index/license
copyright:  Copyright (C) 2001-2003, Simian Systems Inc.
author:  John Luxford <mailto:lux@simian.ca>


[ Top ]


Class Variables

$extra =  ''

[line 103]

A way to pass extra parameters to the HTML form tag, for example 'enctype="multipart/formdata"'.



Tags:

access:  public

Type:   mixed


[ Top ]

$formname =  false

[line 130]

The name of the form. Note: If this is not the first form on the page, then a form name is required (must also set the $name property of the MailForm object).



Tags:

access:  public

Type:   mixed


[ Top ]

$jsFile =  false

[line 140]

The path to the tie.js JavaScript file, which contains the JavaScript components to this widget. This is determined automatically in the constructor.



Tags:

access:  public

Type:   mixed


[ Top ]

$tie =  false

[line 120]

The name of the field to be "tied" to.



Tags:

access:  public

Type:   mixed


[ Top ]

$ties = array ()

[line 151]

This is the list of values to display for each value of the widget this widget is tied to. Ordinary select widgets simply have a $values associative array, but the tie widget has this which is a $values array for each value of the other widget.



Tags:

access:  public

Type:   mixed


[ Top ]

$type =  'tie'

[line 112]

This is the short name for this widget. The short name is the class name minus the 'MF_Widget_' prefix.



Tags:

access:  public

Type:   mixed
Overrides:   Array


[ Top ]



Class Methods


constructor MF_Widget_tie [line 160]

MF_Widget_tie MF_Widget_tie( string $name)

Constructor method.



Tags:

access:  public


Parameters:

string   $name  

[ Top ]

method display [line 212]

string display( [boolean $generate_html = 0])

Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).



Tags:

access:  public


Overrides MF_Widget::display() (Returns the display HTML for this widget. The optional parameter determines whether or not to automatically display the widget nicely, or whether to simply return the widget (for use in a template).)

Parameters:

boolean   $generate_html  

[ Top ]

method includeJS [line 193]

string includeJS( )

Generates the necessary HTML to include the JavaScript components to this widget.



Tags:

access:  public


[ Top ]

method setValues [line 177]

void setValues( string $name, [associative $values = false])

Sets the values to display for the specified value of the other widget, which is specified in $name parameter.



Tags:

access:  public


Overrides MF_Widget::setValues() (Sets the *POSSIBLE* values for this widget. If $value is given, sets $this->value as a hash, otherwise, as a string.)

Parameters:

string   $name  
associative   $values   array $values

[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:19:53 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2