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 1428 of file grima-lib.php.

Member Function Documentation

◆ fromXML()

GrimaForm::fromXML (   $xml)

interpret XML to determine form fields and behavior

Parameters
string$xmlXML document

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

1470  {
1471  $doc = new DomDocument();
1472  $doc->loadXML($xml);
1473  $xpath = new DomXpath($doc);
1474  $this->title = $xpath->query('//Title')[0]->nodeValue;
1475  $this->action = basename($_SERVER['PHP_SELF']); # allow set?
1476 
1477  $nodes = $xpath->query('//Field');
1478  foreach ($nodes as $node) {
1479  $this->fields[$node->getAttribute('name')] = new GrimaFormField($node);
1480  }
1481  }
Wrapper for each field in a form, keeping track of its properties.
Definition: grima-lib.php:1493

◆ loadPersistentValues()

GrimaForm::loadPersistentValues (   $obj)

load persistent values into the form

Parameters
Object$objarray-accessible

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

1454  {
1455  foreach ($this->fields as $field) {
1456  if (($field->persistent) and isset($obj[$field->name])) {
1457  $field->value = $obj[$field->name];
1458  }
1459  }
1460  }

◆ loadValues()

GrimaForm::loadValues (   $obj)

load values into the form

Parameters
Object$objarray-accessible

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

1439  {
1440  foreach ($this->fields as $field) {
1441  if (isset($obj[$field->name])) {
1442  $field->value = $obj[$field->name];
1443  }
1444  }
1445  }

Member Data Documentation

◆ $action

GrimaForm::$action
protected

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

◆ $fields

GrimaForm::$fields = array()

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

◆ $title

GrimaForm::$title

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


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