blueshoes php application framework and cms            core_html
[ class tree: core_html ] [ index: core_html ] [ all elements ]

Class: Bs_FormItAble

Source Location: /core/html/form/Bs_FormItAble.class.php

Class Overview

Bs_Object
   |
   --Bs_FormItAble

we had a discussion about the name of this class. "FormItAble" means "form it", with this class you are ABLE to display classes as FORMS., it's about web forms, and the name comes from "formidable". we think this class deserves this name. :-) an alternative would have been "ClassFormHandler". it's a form handler that builds forms for classes.


Author(s):

Version:

  • 4.5.$Id: Bs_FormItAble.class.php,v 1.10 2003/12/14 09:52:03 andrej Exp $

Copyright:

  • blueshoes.org

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 78]
we had a discussion about the name of this class. "FormItAble" means "form it", with this class you are ABLE to display classes as FORMS., it's about web forms, and the name comes from "formidable". we think this class deserves this name. :-) an alternative would have been "ClassFormHandler". it's a form handler that builds forms for classes.

example: you have a class "car". the car class has the vars carColor, carLength and carSeats. now this class can show a form for these vars. "hint" vars can be used to give more information about the vars and the form.

dataPrefix: by default, the submitted field values will be assigned directly to the class. let's say your class is called $foo, and you have a form field named "bar" then the submitted value will be assigned to $foo->bar. if you want to have it assigned to $foo->data['bar'] instead, you can specify the 'dataPrefix' = 'data' in the hint-hash. if you use groups to separate the fields, you can separate the vars in your class too by specifying the 'dataPrefix' there too, next to the 'caption'. for example:

 	'groups' => array(
 		'grpGeneral' => array(
 			'caption'    => array('en'=>'General', 'de'=>'Allgemein'),
 			'dataPrefix' => 'general',
 		),
 
then a field 'bar' that is in the group 'grpGeneral' will be assigned to $foo->general['bar']. and if you use both, it will be $foo->data['general']['bar']. was that clear?

 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 HINT STRUCTURE:
   The formItAble hint-hash is holding the main info of the class vars that are to be displayed.
   Sample:
      $form_hint_hash = array (
                  'debug'      => array ('checkSopHints'=>TRUE, 'checkHintSyntax'=>TRUE, 'checkClassVars'=>TRUE,
                                        ),
                  'dataPrefix' => string, read above.
            (*)   'props'      => array ( -- All puplic attributes of Bs_Form.class.php / See there. --
                                         ),

                  'groups'     => array ( -- All puplic attributes of Bs_FormContainer.class.php / See there. --
                                         ),
            (*)   'fields'     => array ( -- All puplic attributes of Bs_FormFieldxxxxx.class.php / See there. --
                                         )
      );
   *) Mandatory  \____ ___/           \__________ ____________________________________________________________/
                      V                          V
                  Main Hint Parts       Attributes used to define the form details.

  'debug': (optional)
  ===================
    KEY            | VALUES                | MEANING
  =================+=======================+==============================================================================
  checkSopHints    | { TRUE | FALSE }      | -- not implemented yet -- Default=TRUE - Check the given hint-hash against the given class.
                   | [optional]            | When your certain that types are OK, you may turn this feature off; saving CPU.
                   |                       | See $this->classVarCheck()
  -----------------+-----------------------+------------------------------------------------------------------------------
  checkHintSyntax  | { TRUE | FALSE }      | -- not implemented yet --  Default=TRUE - Check the given hint-hash for syntax error.
                   | [optional]            | When your certain that systax is OK, you may turn this feature off; saving CPU.
                   |                       | See $this->hintsSyntaxCheck()
  -----------------+-----------------------+------------------------------------------------------------------------------
  checkClassVars   | { TRUE | FALSE }      | -- not implemented yet -- Default=TRUE - Check the given hint-hash against the given class.
                   | [optional]            | When your certain that types are OK, you may turn this feature off; saving CPU.
                   |                       | See $this->classVarCheck()
  -----------------+-----------------------+------------------------------------------------------------------------------
 




Tags:

copyright:  blueshoes.org
pattern:  singleton
version:  4.5.$Id: Bs_FormItAble.class.php,v 1.10 2003/12/14 09:52:03 andrej Exp $
author:  andrej arn <at blueshoes dot org>, Sam Blum <sam at blueshoes dot org>


[ Top ]


Class Methods


constructor Bs_FormItAble [line 116]

Bs_FormItAble &Bs_FormItAble( )

constructor



[ Top ]

method buildForm [line 220]

& &buildForm( object &$theObject, [array $overwriteFormProps = NULL])

builds the web form for the given object.



Tags:

return:  instance of Bs_Form
access:  public


Parameters:

object   &$theObject  
array   $overwriteFormProps   (hash with form props to overwrite the defaults of the class. default is NULL.)

[ Top ]

method doItYourself [line 155]

mixed &doItYourself( object &$theObject, [bool $returnFormObj = FALSE], [array $overwriteFormProps = NULL])

does everything itself: fetching form hints, building the form etc.

after a successful submit your obj will have the submitted values in its class vars.

return value:

   if the form has to be displayed you'll get a hash back; the result of Bs_Form->getAll().
   after a successful submit you get:
     - bool TRUE if $returnFormObj is FALSE (default)
     - object (reference to Bs_Form instance) if $returnFormObj is TRUE
 




Tags:

return:  (see above)
throws:  bool FALSE on error, use Bs_Error::getLastErrors()
access:  public


Parameters:

object   &$theObject  
bool   $returnFormObj   (default is FALSE, see above.)
array   $overwriteFormProps   (hash with form props to overwrite the defaults of the class. default is NULL.)

[ Top ]

method _buildGroups [line 381]

void _buildGroups( mixed &$formGroups, mixed $group, mixed $formHints)



[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:10:36 +0100 by phpDocumentor 1.2.3