Grima 2018-08
Whispering into Alma's ear
Public Member Functions | Public Attributes | Protected Attributes | List of all members
GrimaForm Class Reference

A holder for the user inputs to a grima, base on the XML file. More...

Public Member Functions

  loadValues ($obj)
  load values into the form More...
 
  loadPersistentValues ($obj)
  load persistent values into the form More...
 
  fromXML ($xml)
  interpret XML to determine form fields and behavior More...
 

Public Attributes

  $fields = array()
 
  $title
 

Protected Attributes

  $action
 

Detailed Description

A holder for the user inputs to a grima, base on the XML file.

Definition at line 1836 of file grima-lib.php.

Member Function Documentation

◆ fromXML()

GrimaForm::fromXML (   $xml )

interpret XML to determine form fields and behavior

Parameters
string $xml XML document

Definition at line 1879 of file grima-lib.php.

1880 {
1881 $doc = new DomDocument();
1882 $doc->loadXML($xml);
1883 $xpath = new DomXpath($doc);
1884 $this->title = $xpath->query('//Title')[0]->nodeValue;
1885 $this->action = basename($_SERVER['PHP_SELF']); // allow set?
1886
1887 $nodes = $xpath->query('//Field');
1888 foreach ($nodes as $node) {
1889 $this->fields[$node->getAttribute('name')] = new GrimaFormField($node);
1890 }
1891 }
Wrapper for each field in a form, keeping track of its properties.
Definition: grima-lib.php:2074

◆ loadPersistentValues()

GrimaForm::loadPersistentValues (   $obj )

load persistent values into the form

Parameters
Object $obj array-accessible

Definition at line 1864 of file grima-lib.php.

1865 {
1866 foreach ($this->fields as $field) {
1867 if (($field->persistent) and isset($obj[$field->name])) {
1868 $field->value = $obj[$field->name];
1869 }
1870 }
1871 }

◆ loadValues()

GrimaForm::loadValues (   $obj )

load values into the form

Parameters
Object $obj array-accessible

Definition at line 1848 of file grima-lib.php.

1849 {
1850 foreach ($this->fields as $field) {
1851 if (isset($obj[$field->name])) {
1852 $field->value = $obj[$field->name];
1853 }
1854 }
1855 }

Member Data Documentation

◆ $action

GrimaForm::$action
protected

Definition at line 1840 of file grima-lib.php.

◆ $fields

GrimaForm::$fields = array()

Definition at line 1838 of file grima-lib.php.

◆ $title

GrimaForm::$title

Definition at line 1839 of file grima-lib.php.


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