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

Class: QueryTemplatesSyntaxGenerators

Source Location: /home/bob/workspace/QueryTemplates/src/QueryTemplatesSyntaxGenerators.php

Class Overview

phpQueryObject
   |
   --QueryTemplatesSyntaxDOM
      |
      --QueryTemplatesSyntaxValues
         |
         --QueryTemplatesSyntaxCode
            |
            --QueryTemplatesSyntaxConditions
               |
               --QueryTemplatesSyntaxVars
                  |
                  --QueryTemplatesSyntaxGenerators

Class extending phpQueryObject with templating methods.


Author(s):

Methods


Child classes:

QueryTemplatesSyntax
Class extending phpQueryObject with templating methods.

Inherited Variables

Inherited Methods

Class: QueryTemplatesSyntaxVars

QueryTemplatesSyntaxVars::loop()
QueryTemplatesSyntaxVars::loopOne()
QueryTemplatesSyntaxVars::loopSeparate()
QueryTemplatesSyntaxVars::valuesToSelector()
Injects markup from $values' content (rows or attributes) into nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorAfter()
Injects markup from $values' content (rows or attributes) after nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorAppend()
Injects markup from $values' content (rows or attributes) at the end of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorAttr()
Injects markup from $values' content (rows or attributes) as attribute of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorBefore()
Injects markup from $values' content (rows or attributes) before nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorPrepend()
Injects markup from $values' content (rows or attributes) at the beggining of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::valuesToSelectorReplace()
Injects markup from $values' content (rows or attributes) replacing nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varPrint()
Prints variable $varName as matched elements' content.
QueryTemplatesSyntaxVars::varPrintAfter()
Prints variable $varName after matched elements.
QueryTemplatesSyntaxVars::varPrintAppend()
Prints variable $varName on the end of matched elements.
QueryTemplatesSyntaxVars::varPrintAttr()
Prints variable $varName as attribute $attr of matched elements.
QueryTemplatesSyntaxVars::varPrintBefore()
Prints variable $varName before matched elements.
QueryTemplatesSyntaxVars::varPrintPrepend()
Prints variable $varName on beggining of matched elements.
QueryTemplatesSyntaxVars::varPrintReplace()
Prints variable $varName replacing matched elements.
QueryTemplatesSyntaxVars::varsToForm()
Injects executable code which toggles form fields values and selection states according to value of variable $varName.
QueryTemplatesSyntaxVars::varsToLoop()
Wraps selected elements with executable code iterating $varName as $rowName.
QueryTemplatesSyntaxVars::varsToLoopFirst()
Wraps selected elements with executable code iterating $varName as $rowName.
QueryTemplatesSyntaxVars::varsToLoopSeparate()
Wraps selected elements with executable code iterating $varName as $rowName.
QueryTemplatesSyntaxVars::varsToSelector()
Injects executable code printing variable's fields inside nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorAfter()
Injects executable code printing variable's fields after nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorAppend()
Injects executable code printing variable's fields at the end of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorAttr()
Injects executable code printing variable's fields as attribute of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorBefore()
Injects executable code printing variable's fields before nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorPrepend()
Injects executable code printing variable's fields at the beggining of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToSelectorReplace()
Injects executable code printing variable's fields replacing nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxVars::varsToStack()
Injects executable code printing variable's fields inside actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackAfter()
Injects executable code printing variable's fields after actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackAppend()
Injects executable code printing variable's fields at the end of actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackAttr()
Injects executable code printing variable's fields as attribute of actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackBefore()
Injects executable code printing variable's fields before actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackPrepend()
Injects executable code printing variable's fields at the beggining of actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::varsToStackReplace()
Injects executable code printing variable's fields replacing actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays.
QueryTemplatesSyntaxVars::_valuesToSelector()
QueryTemplatesSyntaxVars::_varPrint()
QueryTemplatesSyntaxVars::_varsParseFields()
QueryTemplatesSyntaxVars::_varsToLoop()
QueryTemplatesSyntaxVars::_varsToSelector()
Internal method.
QueryTemplatesSyntaxVars::_varsToStack()

Class: QueryTemplatesSyntaxConditions

QueryTemplatesSyntaxConditions::elseIfCode()
QueryTemplatesSyntaxConditions::elseIfNotVar()
Wraps selected tag with PHP "else if" statement checking if $var evaluates to FALSE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::elseIfPHP()
Wraps selected tag with PHP "else if" statement containing $code as condition.
QueryTemplatesSyntaxConditions::elseIfVar()
Wraps selected tag with PHP "else if" statement checking if $var evaluates to true. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::elsePHP()
Wraps selected tag with PHP "else" statement.
QueryTemplatesSyntaxConditions::elseStatement()
TODO description
QueryTemplatesSyntaxConditions::endOnly()
TODO docs
QueryTemplatesSyntaxConditions::ifCode()
TODO doc
QueryTemplatesSyntaxConditions::ifNotVar()
Wraps selected tag with PHP "if" statement checking if $var evaluates to FALSE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::ifPHP()
Wraps selected tag with PHP "if" statement containing $code as condition.
QueryTemplatesSyntaxConditions::ifVar()
Wraps selected tag with PHP "if" statement checking if $var evaluates to TRUE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::onlyIf()
TODO docs
QueryTemplatesSyntaxConditions::onlyIfNot()
TODO docs
QueryTemplatesSyntaxConditions::onlyJS()
TODO Move to jsCode plugin.
QueryTemplatesSyntaxConditions::onlyPHP()
Honors code between onlyPHP and endOnly, only for PHP templates.
QueryTemplatesSyntaxConditions::tagToElseIfNotVar()
Replaces selected tag with PHP "else if" statement checking if $var evaluates to FALSE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::tagToElseIfPHP()
Replaces selected tag with PHP "else if" statement containing $code as condition.
QueryTemplatesSyntaxConditions::tagToElseIfVar()
Replaces selected tag with PHP "else if" statement checking if $var evaluates to TRUE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::tagToElsePHP()
QueryTemplatesSyntaxConditions::tagToElseStatement()
QueryTemplatesSyntaxConditions::tagToIfNotVar()
Replaces selected tag with PHP "if" statement checking if $var evaluates to FALSE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::tagToIfPHP()
Replaces selected tag with PHP "if" statement containing $code as condition.
QueryTemplatesSyntaxConditions::tagToIfVar()
Replaces selected tag with PHP "if" statement checking if $var evaluates to TRUE. $var must be available inside template's scope.
QueryTemplatesSyntaxConditions::_if()
QueryTemplatesSyntaxConditions::_tagToElse()

Class: QueryTemplatesSyntaxCode

QueryTemplatesSyntaxCode::codeToSelector()
Injects raw executable code inside nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxCode::codeToSelectorAfter()
Injects raw executable code after nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxCode::codeToSelectorAppend()
Injects raw executable code at the end of nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxCode::codeToSelectorAttr()
Injects raw executable code inside attribute of nodes matched by selector.
QueryTemplatesSyntaxCode::codeToSelectorBefore()
Injects raw executable code before nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxCode::codeToSelectorPrepend()
Injects raw executable code at the beggining of nodes matched by selector.
QueryTemplatesSyntaxCode::codeToSelectorReplace()
Injects raw executable code replacing nodes matched by selector. Method uses actually matched nodes as root for the query.
QueryTemplatesSyntaxCode::codeToStack()
Injects raw executable code inside actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackAfter()
Injects raw executable code after actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackAppend()
Injects raw executable code at the beggining of actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackAttr()
Injects raw executable code inside attribute of actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackBefore()
Injects raw executable code before actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackPrepend()
Injects raw executable code at the end of actually matched nodes.
QueryTemplatesSyntaxCode::codeToStackReplace()
Injects raw executable code replacing actually matched nodes.
QueryTemplatesSyntaxCode::_codeToSelector()
QueryTemplatesSyntaxCode::_codeToStack()

Class: QueryTemplatesSyntaxValues

QueryTemplatesSyntaxValues::valuesToForm()
Toggles form fields values and selection states according to static values from $values.
QueryTemplatesSyntaxValues::valuesToLoop()
Method loops provided $values on actually selected nodes. Each time new row is inserted, provided callback is triggered with $dataRow, $node and $dataIndex.
QueryTemplatesSyntaxValues::valuesToLoopBefore()
Method loops provided $values on actually selected nodes. Each time new row is inserted, provided callback is triggered with $dataRow, $node and $dataIndex.
QueryTemplatesSyntaxValues::valuesToLoopFirst()
Method loops provided $values on actually selected nodes. Each time new row is inserted, provided callback is triggered with $dataRow, $node and $dataIndex.
QueryTemplatesSyntaxValues::valuesToLoopSeparate()
Method loops provided $values on actually selected nodes. Each time new row is inserted, provided callback is triggered with $dataRow, $node and $dataIndex.
QueryTemplatesSyntaxValues::valuesToStack()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackAfter()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackAppend()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackAttr()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackBefore()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackPrepend()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::valuesToStackReplace()
Injects markup from $values' content (rows or attributes) inside actually selected nodes.
QueryTemplatesSyntaxValues::_valuesToLoop()
QueryTemplatesSyntaxValues::_valuesToStack()

Class: QueryTemplatesSyntaxDOM

QueryTemplatesSyntaxDOM::attrAppend()
QueryTemplatesSyntaxDOM::attrPrepend()
QueryTemplatesSyntaxDOM::stackToMethod()
Returns array being result of running $method on all stack elements.
QueryTemplatesSyntaxDOM::unWrap()
Removes selected element and moves it's children into parent node.

Class: phpQueryObject

phpQueryObject::__construct()
Enter description here...
phpQueryObject::add()
Enter description here...
phpQueryObject::addClass()
Enter description here...
phpQueryObject::addClassPHP()
Enter description here...
phpQueryObject::after()
Enter description here...
phpQueryObject::afterPHP()
Enter description here...
phpQueryObject::ancestors()
Enter description here...
phpQueryObject::andSelf()
Enter description here...
phpQueryObject::append()
Enter description here...
phpQueryObject::appendPHP()
Enter description here...
phpQueryObject::appendTo()
Enter description here...
phpQueryObject::attr()
phpQueryObject::attrEvents()
phpQueryObject::attrPHP()
Enter description here...
phpQueryObject::before()
Enter description here...
phpQueryObject::beforePHP()
Enter description here...
phpQueryObject::bind()
Binds a handler to one or more events (like click) for each matched element.
phpQueryObject::callback()
Run callback on actual object.
phpQueryObject::change()
Enter description here...
phpQueryObject::children()
Enter description here...
phpQueryObject::click()
Enter description here...
phpQueryObject::contents()
Enter description here...
phpQueryObject::contentsUnwrap()
Enter description here...
phpQueryObject::count()
phpQueryObject::css()
Enter description here...
phpQueryObject::current()
phpQueryObject::debug()
phpQueryObject::documentFragment()
phpQueryObject::dump()
Dump htmlOuter and preserve chain. Usefull for debugging.
phpQueryObject::dumpDie()
Dump htmlOuter and stop script execution. Usefull for debugging.
phpQueryObject::dumpLength()
phpQueryObject::dumpTree()
phpQueryObject::dumpWhois()
phpQueryObject::each()
Enter description here...
phpQueryObject::elementsContainsNode()
phpQueryObject::end()
Enter description here...
phpQueryObject::eq()
Enter description here...
phpQueryObject::extend()
Deprecated, use $pq->plugin() instead.
phpQueryObject::filter()
Enter description here...
phpQueryObject::filterCallback()
Enter description here...
phpQueryObject::find()
Enter description here...
phpQueryObject::get()
Return matched DOM nodes.
phpQueryObject::getDocument()
Returns object with stack set to document root.
phpQueryObject::getDocumentID()
Get object's Document ID.
phpQueryObject::getDocumentIDRef()
Saves object's DocumentID to $var by reference.
phpQueryObject::getDOMDocument()
phpQueryObject::getElementSiblings()
phpQueryObject::getNodeAttrs()
phpQueryObject::getNodeXpath()
Returns node's XPath.
phpQueryObject::getString()
Return matched DOM nodes.
phpQueryObject::getStrings()
Return matched DOM nodes.
phpQueryObject::hasClass()
Enter description here...
phpQueryObject::hide()
phpQueryObject::html()
Enter description here...
phpQueryObject::htmlOuter()
Enter description here...
phpQueryObject::index()
Enter description here...
phpQueryObject::insert()
Internal insert method. Don't use it.
phpQueryObject::insertAfter()
Enter description here...
phpQueryObject::insertBefore()
Enter description here...
phpQueryObject::is()
Enter description here...
phpQueryObject::isChar()
Determines if $char is really a char.
phpQueryObject::isHTML()
phpQueryObject::isRegexp()
phpQueryObject::isRoot()
phpQueryObject::isXHTML()
phpQueryObject::isXML()
phpQueryObject::key()
phpQueryObject::length()
Enter description here...
phpQueryObject::load()
Enter description here...
phpQueryObject::map()
Enter description here...
phpQueryObject::markup()
jQuey difference
phpQueryObject::markupEvents()
phpQueryObject::markupOuter()
jQuey difference
phpQueryObject::markupOuterPHP()
TODO doc
phpQueryObject::markupPHP()
TODO doc
phpQueryObject::matchClasses()
Enter description here...
phpQueryObject::merge()
phpQueryObject::newInstance()
Returns new instance of actual class.
phpQueryObject::next()
Double-function method.
phpQueryObject::nextAll()
phpQueryObject::not()
Enter description here...
phpQueryObject::offsetExists()
phpQueryObject::offsetGet()
phpQueryObject::offsetSet()
phpQueryObject::offsetUnset()
phpQueryObject::parent()
Enter description here...
phpQueryObject::parents()
Enter description here...
phpQueryObject::parseSelector()
phpQueryObject::php()
Just like html(), but returns markup with VALID (dangerous) PHP tags.
phpQueryObject::plugin()
Enter description here...
phpQueryObject::prepend()
Enter description here...
phpQueryObject::prependPHP()
Enter description here...
phpQueryObject::prependTo()
Enter description here...
phpQueryObject::prev()
Enter description here...
phpQueryObject::prevAll()
phpQueryObject::pseudoClasses()
phpQueryObject::remove()
Enter description here...
phpQueryObject::removeAttr()
Enter description here...
phpQueryObject::removeClass()
Enter description here...
phpQueryObject::replaceAll()
Enter description here...
phpQueryObject::replaceWith()
Enter description here...
phpQueryObject::replaceWithPHP()
Enter description here...
phpQueryObject::reverse()
Enter description here...
phpQueryObject::rewind()
phpQueryObject::runQuery()
phpQueryObject::serialize()
Enter description here...
phpQueryObject::serializeArray()
Enter description here...
phpQueryObject::show()
phpQueryObject::siblings()
Enter description here...
phpQueryObject::size()
Enter description here...
phpQueryObject::slice()
Enter description here...
phpQueryObject::stack()
Internal stack iterator.
phpQueryObject::stackIsRoot()
phpQueryObject::submit()
Enter description here...
phpQueryObject::switchWith()
Enter description here...
phpQueryObject::text()
Return joined text content.
phpQueryObject::toggleClass()
Enter description here...
phpQueryObject::toReference()
Saves actual object to $var by reference.
phpQueryObject::toRoot()
Enter description here...
phpQueryObject::trigger()
Trigger a type of event on every matched element.
phpQueryObject::triggerHandler()
This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browsers default actions.
phpQueryObject::unbind()
Enter description here...
phpQueryObject::unloadDocument()
Unloads whole document from memory.
phpQueryObject::unQuote()
phpQueryObject::val()
Return form element value.
phpQueryObject::valid()
phpQueryObject::whois()
phpQueryObject::wrap()
Enter description here...
phpQueryObject::wrapAll()
Enter description here...
phpQueryObject::wrapAllOld()
Enter description here...
phpQueryObject::wrapAllPHP()
Enter description here...
phpQueryObject::wrapInner()
Enter description here...
phpQueryObject::wrapInnerPHP()
Enter description here...
phpQueryObject::wrapPHP()
Enter description here...
phpQueryObject::xml()
phpQueryObject::xmlOuter()
phpQueryObject::_clone()
Enter description here...
phpQueryObject::_empty()
Proper name without underscore (just ->empty()) also works.
phpQueryObject::_next()
Safe rename of next().
phpQueryObject::_prev()
Use prev() and next().
phpQueryObject::__call()
phpQueryObject::__get()
phpQueryObject::__loadSuccess()
phpQueryObject::__pseudoClassParam()
phpQueryObject::__toString()
phpQueryObject::___wrapAllCallback()

Class Details

[line 11]
Class extending phpQueryObject with templating methods.



Tags:

author:  Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
link:  http://code.google.com/p/querytemplates/
abstract:  
license:  MIT License


[ Top ]


Class Methods


static method _formFromVars_CodeValue [line 1348]

static void _formFromVars_CodeValue( $self, $scope)



Tags:

access:  protected


Parameters:

   $self  
   $scope  

[ Top ]

method formFromValues [line 304]

QueryTemplatesParse formFromValues( Array $record, Array $structure, [Array $errors = null], [Array $data = null], [Array|String $template = null], [Array $selectors = null], [Array|String|Callback $fieldCallback = null])

Method formFromVars acts as flexible form helper. It creates customized pure-markup form without the need of suppling a line of markup.

Final form is available right after using this method.

Created form have following features:

  • shows data from record
  • shows errors
  • supports default values
  • supports radios and checkboxes
  • supports select elements with optgroups
  • supports select multiple
Created form can be customized using:
  • input wrapper template (per field name, per field type and default)
  • selectors (for input, label and errors)
  • callbacks (per field)
== Example ==
  1.  $structure array(
  2.      '__form' => array('id' => 'myFormId'),
  3.      array(
  4.          '__label' => 'Fieldset 1 legend',
  5.          'default-field' => array(    // 'text' is default
  6.              'label' => 'default-field label',
  7.              'id' => 'default-field-id',
  8.          ),
  9.          'text-field' => array('text',
  10.              'label' => 'text-field label',
  11.              'id' => 'text-field-id',
  12.          ),
  13.          'hidden-field' => 'hidden',
  14.          'checkbox-field' => 'checkbox',
  15.      ),
  16.      array(
  17.          '__label' => 'Fieldset 2 legend',
  18.          'select-field' => array('select',
  19.              'label' => 'select-field label',
  20.          ),
  21.          'radio-field' => array('radio',
  22.              'values' => array('possibleValue1''possibleValue2')
  23.          ),
  24.          'textarea-field' => 'textarea',
  25.      ),
  26.  );
  27.  $data array(
  28.      'select-field' => array(
  29.          // no optgroup
  30.          'bar1' => 'bar1 label',
  31.          'bar2' => 'bar2 label',
  32.          'bar3' => 'bar3 label',
  33.      ),
  34.  );
  35.  $record array(
  36.    'text-field' => 'value from record',
  37.  );
  38.  $tempalte->
  39.    formFromValues($record$structurenull$data)
  40.  ;
=== Result DOM tree ===
  1.  form#myFormId
  2.   - fieldset
  3.   -  - input#myFormId_hidden-field[name="hidden-field"][value="new hidden-fiel"]
  4.   -  - legend
  5.   -  -  - Text:Fieldset lege
  6.   -  - div.input.text
  7.   -  -  - label
  8.   -  -  -  - Text:default-field l
  9.   -  -  - input#default-field-id[name="default-field"]
  10.   -  - div.input.text
  11.   -  -  - label
  12.   -  -  -  - Text:text-field labe
  13.   -  -  - input#text-field-id[name="text-field"][value="new text-field "]
  14.   -  -  - ul.errors
  15.   -  -  -  - li
  16.   -  -  -  -  - Text:text-field erro
  17.   -  - div.input.checkbox
  18.   -  -  - div
  19.   -  -  -  - Text:Checkbox field
  20.   -  -  - label
  21.   -  -  -  - Text:Checkbox-field
  22.   -  -  - input#myFormId_checkbox-field[name="checkbox-field"][value="1"][checked]
  23.   - fieldset
  24.   -  - legend
  25.   -  -  - Text:Fieldset lege
  26.   -  - div.input.select
  27.   -  -  - label
  28.   -  -  -  - Text:select-field la
  29.   -  -  - select[name="select-field"]
  30.   -  -  -  - option[value="bar1"]
  31.   -  -  -  -  - Text:bar1 label
  32.   -  -  -  - option[value="bar2"]
  33.   -  -  -  -  - Text:bar2 label
  34.   -  -  -  - option[value="bar3"][selected]
  35.   -  -  -  -  - Text:bar3 label
  36.   -  - div.input.select
  37.   -  -  - label
  38.   -  -  -  - Text:select-field-op
  39.   -  -  - select[name="select-field-optgroups-multiple"]
  40.   -  -  -  - optgroup
  41.   -  -  -  -  - option[value="group1_1"]
  42.   -  -  -  -  -  - Text:group1_1 label
  43.   -  -  -  -  - option[value="group1_2"]
  44.   -  -  -  -  -  - Text:group1_2 label
  45.   -  -  -  - optgroup
  46.   -  -  -  -  - option[value="group2_1"][selected]
  47.   -  -  -  -  -  - Text:group2_1 label
  48.   -  -  -  -  - option[value="group2_2"]
  49.   -  -  -  -  -  - Text:group2_2 label
  50.   -  -  -  - option[value="bar"][selected]
  51.   -  -  -  -  - Text:Bar
  52.   -  -  - ul.errors
  53.   -  -  -  - li
  54.   -  -  -  -  - Text:error1
  55.   -  -  -  - li
  56.   -  -  -  -  - Text:error2
  57.   -  - div.input.radio
  58.   -  -  - label
  59.   -  -  -  - Text:Radio-field
  60.   -  -  - input[name="radio-field"][value="possibleValue1"]
  61.   -  -  - input[name="radio-field"][value="possibleValue2"][checked]
  62.   -  - div.input.textarea
  63.   -  -  - label
  64.   -  -  -  - Text:Textarea-field
  65.   -  -  - textarea#myFormId_textarea-field




Tags:

see:  QueryTemplatesPhpQuery::formFromVars()
see:  QueryTemplatesPhpQuery::varsToForm()
see:  QueryTemplatesPhpQuery::valuesToForm()
TODO:  support objects for record and data
TODO:  maybe support callbacks per input type, before/after, maybe for errors too ?
TODO:  fieldCallback __form special field for form callback
TODO:  hidden fields and fieldCallback


Parameters:

Array   $record   TODO doc
Array   $structure   Form structure information. This should be easily fetchable from ORM layer. Possible types:
  • text (default)
  • password
  • hidden
  • checkbox
  • radio
  • textarea
Convention:
  1.  'fieldName' => array(
  2.    'fieldType'$fieldOptions
  3.  )
Where $fieldOptions can be (`key => value` pairs):
  • label
  • id
  • multiple (only select)
  • values (only radio, MANDATORY)
  • value (only checkbox, optional)
There can be special field *`__form`*, which represents form element, as an array. All values from it will be pushed as form attributes. If you wrap fields' array within another array, it will represent *fieldsets*, which value with index *`__label`* will be used as legend (optional).
Array   $errors   TODO doc
Array   $data   Additional data for fields. For now it's only used for populating select boxes. Example:
  1.  $defaultData array(
  2.      'select-field-optgroups' => array(
  3.          array(    // 1st optgroup
  4.              '__label' => 'optgroup 1 label',
  5.              'group1_1' => 'group1_1 label',
  6.              'group1_2' => 'group1_2 label',
  7.          ),
  8.          array(    // 2nd optgroup
  9.              '__label' => 'optgroup 2 label',
  10.              'group2_1' => 'group2_1 label',
  11.              'group2_2' => 'group2_2 label',
  12.          ),
  13.          'bar' => 'Bar',    // no optgroup
  14.      ),
  15.  );
Array|String   $template   Input wrapper template. This template will be used for each field. Use array to per field template, '__default' means default. All types allowed in $structure can be used as per-type default template when indexed like '__$type' ex '__checkbox'. To each input wrapper will be added a class which is field's type. Example:
  1.  $templates['__checkbox''
  2.  <div class="input">
  3.      <div>Checkbox field below</div>
  4.    <label/>
  5.    <input/>
  6.  </div>';
Default template is:
  1.  <div class="input">
  2.    <label/>
  3.    <input/>
  4.    <ul class="errors">
  5.      <li/>
  6.    </ul>
  7.  </div>
Array   $selectors   Array of selectors indexed by it's type. Allows to customize lookups inside inputs wrapper. Possible values are:
  • error - selects field's error wrapper
    • dafault value is '.errors'
  • label - selects field's label node (can be div, span, etc)
    • default value is 'label:first'
    • use array to per field name selector, '__default' means default
  • input - selects field's input node: input, textarea or select
    • default value is 'input:first'
    • use array to per field name selector, '__default' means default
    • %t is replaced by field node type (use it with customized per field $template)
Array|String|Callback   $fieldCallback   Callback triggered after preparation of each field.

[ Top ]

method formFromVars [line 762]

QueryTemplatesParse formFromVars( String|Array $varNames, Array $structure, [Array $defaultRecord = null], [Array $defaultData = null], [Array|String $template = null], [Array $selectors = null], [Array|String|Callback $fieldCallback = null])

EXPERIMENTAL - works, but not for production code

Method formFromVars acts as flexible form helper. It creates customized exacutable form without the need of suppling a line of markup.

Form code is executed during template-execution and creates final form using record from variable.

Created form have following features:

  • shows data from record (array or object)
  • shows errors
  • supports default values
  • supports radios and checkboxes
  • supports select elements with optgroups
  • overloadable $defaultData
  • overloadable $defaultRecord
Created form can be customized using:
  • input wrapper template (per field name, per field type and default)
  • selectors (for input, label and errors)
  • callbacks (per field)
== Example ==
  1.  $structure array(
  2.      '__form' => array('id' => 'myFormId'),
  3.      array(
  4.          '__label' => 'Fieldset 1 legend',
  5.          'default-field' => array(    // 'text' is default
  6.              'label' => 'default-field label',
  7.              'id' => 'default-field-id',
  8.          ),
  9.          'text-field' => array('text',
  10.              'label' => 'text-field label',
  11.              'id' => 'text-field-id',
  12.          ),
  13.          'hidden-field' => 'hidden',
  14.          'checkbox-field' => 'checkbox',
  15.      ),
  16.      array(
  17.          '__label' => 'Fieldset 2 legend',
  18.          'select-field' => array('select',
  19.              'label' => 'select-field label',
  20.          ),
  21.          'select-field-optgroups-multiple' => array('select',
  22.              'label' => 'select-field-optgroups label',
  23.          ),
  24.          'radio-field' => array('radio',
  25.              'values' => array('possibleValue1''possibleValue2')
  26.          ),
  27.          'textarea-field' => 'textarea',
  28.      ),
  29.  );




Tags:

see:  QueryTemplatesPhpQuery::varsToForm()
see:  QueryTemplatesPhpQuery::valuesToForm()
see:  QueryTemplatesPhpQuery::formFromValues()
TODO:  move radio values to data
TODO:  support objects for record and data
TODO:  move checkbox values to data
TODO:  select[multiple]
TODO:  write methods used here as part of syntax classes
TODO:  hidden fields and fieldCallback
TODO:  maybe support callbacks per input type, before/after, maybe for errors too ?
TODO:  make checkbox and radios like select


Parameters:

String|Array   $varNames   Array of names of following vars:
  • record [0] Represents actual record as array of fields.
  • errors [1] Represents actual errors as array of fields. Field can also be an array.
  • data [2] Overloads $defaultData during template's execution.
Names should be without dollar signs. Ex:
  1.  array('row''errors.row''data');
  2.  $errors['row'array(
  3.    'field1' => 'one error',
  4.    'field2' => array('first error''second error')
  5.  );
Array   $structure   Form structure information. This should be easily fetchable from ORM layer. Possible types:
  • text (default)
  • password
  • hidden
  • checkbox
  • radio
  • textarea
Convention:
  1.  'fieldName' => array(
  2.    'fieldType'$fieldOptions
  3.  )
Where $fieldOptions can be (`key => value` pairs):
  • label
  • id
  • multiple (only select) // TODO
  • values (only radio, MANDATORY)
  • value (only checkbox, optional)
There can be special field *`__form`*, which represents form element, as an array. All values from it will be pushed as form attributes. If you wrap fields' array within another array, it will represent *fieldsets*, which value with index *`__label`* will be used as legend (optional).
Array   $defaultRecord   Default field's value. Used when field isn't present within supplied record. Ex:
  1.  $defaultRecord array(
  2.      'text-field' => 'text-field default value',
  3.      'select-field' => 'bar2',
  4.      'select-field-optgroups-multiple' => array('group2_1''group2_2'),
  5.      'checkbox-field' => false,
  6.  );
Array   $defaultData   Additional data for fields. For now it's only used for populating select boxes. Example:
  1.  $defaultData array(
  2.      'select-field-optgroups' => array(
  3.          array(    // 1st optgroup
  4.              '__label' => 'optgroup 1 label',
  5.              'group1_1' => 'group1_1 label',
  6.              'group1_2' => 'group1_2 label',
  7.          ),
  8.          array(    // 2nd optgroup
  9.              '__label' => 'optgroup 2 label',
  10.              'group2_1' => 'group2_1 label',
  11.              'group2_2' => 'group2_2 label',
  12.          ),
  13.          'bar' => 'Bar',    // no optgroup
  14.      ),
  15.  );
Array|String   $template   Input wrapper template. This template will be used for each field. Use array to per field template, '__default' means default. All types allowed in $structure can be used as per-type default template when indexed like '__$type' ex '__checkbox'. To each input wrapper will be added a class which is field's type. Example:
  1.  $templates['__checkbox''
  2.  <div class="input">
  3.      <div>Checkbox field below</div>
  4.    <label/>
  5.    <input/>
  6.  </div>';
Default template is:
  1.  <div class="input">
  2.    <label/>
  3.    <input/>
  4.    <ul class="errors">
  5.      <li/>
  6.    </ul>
  7.  </div>
Array   $selectors   Array of selectors indexed by it's type. Allows to customize lookups inside inputs wrapper. Possible values are:
  • error - selects field's error wrapper
    • dafault value is '.errors'
  • label - selects field's label node (can be div, span, etc)
    • default value is 'label:first'
    • use array to per field name selector, '__default' means default
  • input - selects field's input node: input, textarea or select
    • default value is 'input:first'
    • use array to per field name selector, '__default' means default
    • %t is replaced by field node type (use it with customized per field $template)
Array|String|Callback   $fieldCallback   Callback triggered after preparation of each field.

[ Top ]

method inputsFromValues [line 51]

QueryTemplatesParse|QueryTemplatesPhpQuery inputsFromValues( $data $data, [$type $type = 'hidden'])

Creates markup with INPUT tags and prepends it to form.

If selected element isn't a FORM then find('form') is executed.

Method doesn't change selected elements stack.

== Example ==

=== Markup ===

  1.  <form>
  2.    <input name='was-here-before'>
  3.  </form>

=== Data ===

  1.  $data array('field1' => 'foo''field2' => 'bar');

=== `QueryTemplates` formula ===

  1.  $template->inputsFromValues($data);

=== Template ===

  1.  <form>
  2.    <input name='field1' value='foo'>
  3.    <input name='field2' value='bar'>
  4.    <input name='was-here-before'>
  5.  </form>




Tags:

see:  QueryTemplatesPhpQuery::formFromValues()
access:  public


Parameters:

$data   $data  
$type   $type  

[ Top ]

method saveAsVar [line 1443]

void saveAsVar( $name)



Tags:

deprecated:  
access:  public


Parameters:

   $name  

[ Top ]

method saveTextAsVar [line 1449]

void saveTextAsVar( $name)



Tags:

deprecated:  
access:  public


Parameters:

   $name  

[ Top ]

method valuesToVars [line 1421]

void valuesToVars( $varsArray)



Tags:

deprecated:  
access:  public


Parameters:

   $varsArray  

[ Top ]

method varsFromStack [line 1433]

void varsFromStack( String $name)

Saves markupOuter() as value of variable $var avaible in template scope.



Tags:

TODO:  support second $method param
TODO:  user self::parent for storing vars
access:  public


Parameters:

String   $name   New variable name.

[ Top ]

method varsFromStackText [line 1460]

void varsFromStackText( String $name)

Saves text() as value of variable $var avaible in template scope.



Tags:

TODO:  user self::parent for storing vars
access:  public


Parameters:

String   $name   New variable name.

[ Top ]

method varsFromValues [line 1413]

QueryTemplatesParse|QueryTemplatesPhpQuery varsFromValues( array $varsArray)

Behaves as var_export, dumps variables from $varsArray as $key = value for later use during template execution. Variables are prepended into selected elemets.

Method doesn't change selected elements stack.

== Example ==

=== Markup ===

  1.  <node1>
  2.      <node2></node2>
  3.  </node1>

=== Data ===

  1.  $values array('<foo/>''<bar/>');

=== `QueryTemplates` formula ===

  1.  $template['node1']->
  2.    varsFromValues($values)
  3.  ;

=== Template ===

  1.  <node1><?php  $'<foo/>';
  2.  $'<bar/>';  ?><node2></node2></node1>

=== Template tree before ===

  1.  node1
  2.   - node2

=== Template tree after ===

  1.  node1
  2.   - PHP
  3.   - node2




Tags:

access:  public


Parameters:

array   $varsArray  

[ Top ]


Documentation generated on Sat, 07 Mar 2009 12:08:31 +0100 by phpDocumentor 1.4.2