Item
[ class tree: Item ] [ index: Item ] [ all elements ]

Class: Formagic_Item_Abstract

Source Location: /Item/Abstract.php

Class Overview


Abstract superclass for Formagic items


Author(s):

  • Florian Sonnenburg

Version:

  • $Id: Abstract.php 126 2011-05-18 18:41:58Z meweasle $

Copyright:

  • Copyright (c) 2007-2011 Florian Sonnenburg

Variables

Methods


Child classes:

Formagic_Item_Checkbox
Formagic_Item_Checkbox
Formagic_Item_Password
Password type input field for formagic formgenerator
Formagic_Item_Radio
Input type radio for formagic formgenerator
Formagic_Item_Textarea
Formagic_Item_Textarea
Formagic_Item_Submit
Formagic submit button item
Formagic_Item_Html
Displays it's value as plain text, with no input possibility.
Formagic_Item_Hidden
Formagic_Item_Hidden
Formagic_Item_Container
Formagic Container Item class
Formagic_Item_Upload
Formagic_Item_Upload
Formagic_Item_Select
formagicItemSelect
Formagic_Item_Button
Formagic submit button item
Formagic_Item_Input
Formagic_Item_Input

Class Details

[line 31]
Abstract superclass for Formagic items



Tags:

author:  Florian Sonnenburg
version:  $Id: Abstract.php 126 2011-05-18 18:41:58Z meweasle $
copyright:  Copyright (c) 2007-2011 Florian Sonnenburg
abstract:  


[ Top ]


Class Variables

$_attributes = array()

[line 67]

Additional attributes for item HTML tag



Tags:

access:  protected

Type:   array


[ Top ]

$_filteredValue =

[line 37]

Filtered item value cache



Tags:

access:  private

Type:   mixed


[ Top ]

$_filters = array()

[line 85]

Array of input filters for this item



Tags:

access:  protected

Type:   array


[ Top ]

$_isDisabled =  false

[line 103]

Determines if item is removed from Formagic form.



Tags:

access:  protected

Type:   boolean


[ Top ]

$_isFixed =  false

[line 115]

Determines if value can be changed.



Tags:

access:  protected

Type:   boolean


[ Top ]

$_isHidden =  false

[line 97]

Determines if item will be displayed



Tags:

access:  protected

Type:   boolean


[ Top ]

$_isIgnored =  false

[line 109]

Determines if item content should be interpreted after submit.



Tags:

access:  protected

Type:   boolean


[ Top ]

$_isReadonly =  false

[line 91]

Determines if item content can be edited.



Tags:

access:  protected

Type:   boolean


[ Top ]

$_label =  ''

[line 61]

Form item label



Tags:

access:  protected

Type:   boolean


[ Top ]

$_name =

[line 49]

Form item name



Tags:

access:  protected

Type:   string


[ Top ]

$_requiredAttributes = array('id', 'name')

[line 73]

Array of required attributes for this item



Tags:

access:  protected

Type:   array


[ Top ]

$_rules = array()

[line 79]

Array of rule object that are applied for this item



Tags:

access:  protected

Type:   array


[ Top ]

$_value =

[line 55]

Item value



Tags:

access:  protected

Type:   mixed


[ Top ]

$_violatedRules = array()

[line 43]

Violated rule after validation



Tags:

access:  private

Type:   Form_Rule_Abstract


[ Top ]



Class Methods


constructor __construct [line 125]

void __construct( string $name, [array $arguments = null])

Constructor



Tags:

throws:  Formagic_Exception
access:  public


Parameters:

string   $name   Name of item
array   $arguments   Additional arguments

[ Top ]

method addAttribute [line 360]

Formagic_Item_Abstract addAttribute( string $name, string $value)

Adds an HTML attribute to the attributes stack.

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Parameters:

string   $name   Attribute name
string   $value   Attribute value

[ Top ]

method addFilter [line 520]

Formagic_Item_Abstract addFilter( $filter, [ $args = null], mixed $rule)

Adds filter object to Formagic item

Formagic items can have multiple filters which will be applied in the order they are passed to the object.

First parameter $filter can either be a string or an object of a class that extends Formagic_Filter_Interface. A string value is assumed to be the type of filter to be added.

This method throws an exception if no valid role object can be identified.

Implements a fluent interface pattern.




Tags:

return:  object
throws:  Formagic_Exception
access:  public


Overridden in child classes as:

Formagic_Item_Container::addFilter()
Adds a filter to this container and all contained items.

Parameters:

mixed   $rule   Filter type string or Formatic_Filter_Interface object.
array   $args   Optional array of arguments. Will be passed to the filter constructor as array.
   $filter  

[ Top ]

method addRule [line 485]

Formagic_Item_Abstract addRule( mixed $rule, [ $args = array()])

Adds rule object to Formagic item

Formagic items can have multiple rules which will be applied in the order they are passed to the object.

First parameter $rule can either be a string or an instance of a class that extends Formagic_Rule_Abstract. A string value is assumed to be the type of rule to be added.

Implements a fluent interface pattern.




Tags:

return:  This object.
throws:  Formagic_Exception If no valid role object can be identified.
access:  public


Overridden in child classes as:

Formagic_Item_Container::addRule()
Adds a rule to this container and all contained items.

Parameters:

mixed   $rule   Rule type string or Formagic_Rule_Abstract object.
array   $args   Optional array of arguments. Will be passed to the rule constructor as array.

[ Top ]

method getAttribute [line 393]

string getAttribute( $name)

Returns the attributes array for this item.



Tags:



Parameters:

   $name  

[ Top ]

method getAttributes [line 373]

array getAttributes( )

Returns the attributes array for this item.



Tags:

return:  The attributes array.
see:  Formagic_Item_Abstract::setAttributes()
see:  Formagic_Item_Abstract::addAttribute()
access:  public


[ Top ]

method getAttributeStr [line 444]

string getAttributeStr( )

Returns attribute string for HTML tag.

Takes the attributes array and transforms it into a string that can be directly inserted into a HTML tag. The string will be built with a trailing space character.

Two default attributes are added to the attributes string: 'name' and 'id'. If you want to skip these, add them to your attributes on item generation or via setAttributes() or addAttribute() with NULL as value.

  1.  $item->setAttributes(array('class' => 'myclass''onclick' => 'alert('Formagic');'));
  2.  $string $item->getAttributeStr();
  3.  echo '<input type="text"' $string ' />';
  4.  // output will be:
  5.  // <input type="text" id="item" name="item" class="myclass" onclick="alert('Formagic');" />




Tags:

return:  The attributes string.
see:  Formagic_Item_Abstract::setAttributes()
see:  Formagic_Item_Abstract::addAttribute()
access:  public


[ Top ]

method getHtml [line 302]

string getHtml( )

HTML template for renderers that use HTML-Code.

Should be overwritten by subclasses.




Tags:

return:  The HTML string representation of this item.
access:  public


Overridden in child classes as:

Formagic_Item_Checkbox::getHtml()
Returns HTML representation of checkbox item.
Formagic_Item_Password::getHtml()
Returns string representation of password item.
Formagic_Item_Radio::getHtml()
Returns string with HTML representation of radio elements
Formagic_Item_Textarea::getHtml()
HTML string representation of text input field
Formagic_Item_Submit::getHtml()
HTML string representation of submit button
Formagic_Item_ImageSubmit::getHtml()
HTML string representation of submit button
Formagic_Item_Html::getHtml()
HTML string representation of text input field
Formagic_Item_Hidden::getHtml()
Formagic_Item_Upload::getHtml()
HTML string representation of upload input field
Formagic_Item_Select::getHtml()
HTML representation of Formagic select item
Formagic_Item_Button::getHtml()
HTML string representation of submit button
Formagic_Item_Input::getHtml()
HTML string representation of text input field

[ Top ]

method getLabel [line 291]

string getLabel( )

Returns label for this item.



Tags:

return:  The label string.
access:  public


Overridden in child classes as:

Formagic_Item_Submit::getLabel()
Label is already defined by value property
Formagic_Item_ImageSubmit::getLabel()
Returns label for this item.
Formagic_Item_Button::getLabel()
Label is already defined by value property

[ Top ]

method getName [line 233]

string getName( )

Returns the item name.



Tags:

return:  The item name
access:  public


[ Top ]

method getUnfilteredValue [line 243]

mixed getUnfilteredValue( )

Returns current unfiltered value for this item.



Tags:

return:  The unfiltered item value
access:  public


[ Top ]

method getValue [line 253]

mixed getValue( )

Returns the current filtered value for this item.



Tags:

return:  The filtered item value
access:  public


Overridden in child classes as:

Formagic_Item_Container::getValue()
Returns values of all stored items.

[ Top ]

method getViolatedRules [line 630]

array getViolatedRules( )

Returns array of violated rules.

If no rules were violated or if no validation has been performed yet, an empty array will be returned.




Tags:

return:  The violated rules.
access:  public


[ Top ]

method hasFilter [line 541]

boolean hasFilter( string $filterName)



Tags:

access:  public


Parameters:

string   $filterName  

[ Top ]

method hasRule [line 572]

boolean hasRule( $ruleName, string $rule)

Tells if a rule exists for this item.

The $ruleName parameter has to be a string with the name of rule that is looked for. If you want to know for example if the item has the mandatory rule added, $ruleName would have to be 'mandatory'.

The search string is is case insensitive.

  1.  <?php
  2.  // add a rule to the item object
  3.  $mandatory new Formagic_Rule_Mandatory();
  4.  $item->addRule($mandatory);
  5.  
  6.  // look for the rule
  7.  $ruleExists $item->hasRule('mandatory')// would return TRUE
  8.  $ruleExists $item->hasRule('Mandatory')// would return TRUE
  9.  $ruleExists $item->hasRule('Formagic_Rule_Mandatory')// would return FALSE
  10.  ?>




Tags:

access:  public


Parameters:

string   $rule   Rule name, eg. 'Mandatory'
   $ruleName  

[ Top ]

method isDisabled [line 715]

boolean isDisabled( )

Returns disabled status of item



Tags:

return:  The disabled status.
access:  public


[ Top ]

method isHidden [line 668]

boolean isHidden( )

Returns hidden status of item



Tags:

return:  The hidden status.
access:  public


[ Top ]

method isIgnored [line 692]

boolean isIgnored( )

Returns ignore status of item



Tags:

return:  The ignored status.
access:  public


[ Top ]

method printInfo [line 204]

string printInfo( )

Prints item infos.



Tags:

return:  The item information string
access:  public


[ Top ]

method setAttributes [line 345]

Formagic_Item_Abstract setAttributes( array $attArray)

Sets additional attributes for this item.

Mainly used for additional HTML attributes other than "name", "id" or "value", such as "style", "class", javascript-handlers etc. Attributes are added corresponding to key->value-pairs in $attArray.

setAttributes() will overwrite any previously added item attributes.

Implements a fluent interface pattern.




Tags:

return:  This object.
see:  Formagic_Item_Abstract::addAttribute()
access:  public


Parameters:

array   $attArray   The new

[ Top ]

method setDisabled [line 704]

Formagic_Item_Abstract setDisabled( $flag)

Sets disabled flag for item and removes it from form

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Overridden in child classes as:

Formagic_Item_Container::setDisabled()
Disables container item and all its descendants and thus removes all involved items from form.

Parameters:

   $flag  

[ Top ]

method setFixed [line 731]

Formagic_Item_Abstract setFixed( boolean $flag)

Sets isFixed flag.

If set to true, all following calls to setValue() will be ignored.

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Parameters:

boolean   $flag   IsFixed flag value.

[ Top ]

method setHidden [line 657]

Formagic_Item_Abstract setHidden( boolean $flag)

Sets hidden flag for item.

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Overridden in child classes as:

Formagic_Item_Container::setHidden()
Sets hidden flag on container item and all its descendants.

Parameters:

boolean   $flag   Hidden status flag.

[ Top ]

method setIgnore [line 681]

Formagic_Item_Abstract setIgnore( boolean $flag)

Defines if the item will be ignored in form submit.

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Parameters:

boolean   $flag   Ignored status flag.

[ Top ]

method setReadonly [line 643]

Formagic_Item_Abstract setReadonly( boolean $flag)

Sets readonly flag

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Overridden in child classes as:

Formagic_Item_Container::setReadonly()
Sets readonly flag to container item and all its descendants.

Parameters:

boolean   $flag   Readonly status flag.

[ Top ]

method setRequiredAttributes [line 324]

void setRequiredAttributes( $requiredAttributes)



Tags:

access:  public


Parameters:

array   $requiredAttributes  

[ Top ]

method setValue [line 315]

Formagic_Item_Abstract setValue( mixed $value)

Sets the item value to $value.

Implements a fluent interface pattern.




Tags:

return:  This object.
access:  public


Overridden in child classes as:

Formagic_Item_Container::setValue()
Sets new values for all items assigned to this container.
Formagic_Item_Upload::setValue()
Overwrites the superclass method Formagic_Item_Abstract::setValue().

Parameters:

mixed   $value   The new item value.

[ Top ]

method validate [line 586]

boolean validate( )

Performs rule checks

Iterates through all defined rules of Formagic item. Returns true if all rules apply or false otherwise.




Tags:

return:  The validation result.
access:  public


Overridden in child classes as:

Formagic_Item_Container::validate()
Validates contained items.

[ Top ]

method _buildAttributeStr [line 455]

string _buildAttributeStr( $attributes)



Tags:

access:  protected


Parameters:

array   $attributes  

[ Top ]

method _filterValue [line 270]

void _filterValue( $filter, $subject)



Tags:

access:  protected


Parameters:

Formagic_Filter_Interface   $filter  
   $subject  

[ Top ]

method _init [line 195]

void _init( array $additionalArgs)

Allow subclass initialization.



Tags:

access:  protected


Overridden in child classes as:

Formagic_Item_Radio::_init()
Radio item initialization.
Formagic_Item_Submit::_init()
Subclass initialization
Formagic_Item_ImageSubmit::_init()
Subclass initialization.
Formagic_Item_Html::_init()
Formagic_Item_Html::_init()
Formagic_Item_Hidden::_init()
Object initialisation.
Formagic_Item_Select::_init()
Generic argument handler
Formagic_Item_Button::_init()
Subclass initialization

Parameters:

array   $additionalArgs   Array of arguments that are not processed by superclass.

[ Top ]

method _makeDomId [line 743]

string _makeDomId( string $str)

Takes a string and returns a valid DOM ID.



Tags:

return:  Valid DOM ID
access:  private


Parameters:

string   $str   String to convert to a DOM ID

[ Top ]

method _validateItemValue [line 605]

boolean _validateItemValue( $rule, string|array $subject)

Perform validation on item value.



Tags:

return:  Validation result
access:  protected


Parameters:

Formagic_Rule_Abstract   $rule   Validation rule object
string|array   $subject   Validation subject

[ Top ]

method __toString [line 223]

string __toString( )

Returns the HTML string representation of the form item.



Tags:

return:  The HTML string representation.
access:  public


[ Top ]


Documentation generated on Sun, 22 May 2011 22:40:04 +0200 by phpDocumentor 1.4.3