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

1600  {
1601  $doc = new DomDocument();
1602  $doc->loadXML($xml);
1603  $xpath = new DomXpath($doc);
1604  $this->title = $xpath->query('//Title')[0]->nodeValue;
1605  $this->action = basename($_SERVER['PHP_SELF']); # allow set?
1606 
1607  $nodes = $xpath->query('//Field');
1608  foreach ($nodes as $node) {
1609  $this->fields[$node->getAttribute('name')] = new GrimaFormField($node);
1610  }
1611  }
Wrapper for each field in a form, keeping track of its properties.
Definition: grima-lib.php:1786

◆ loadPersistentValues()

GrimaForm::loadPersistentValues (   $obj )

load persistent values into the form

Parameters
Object $obj array-accessible

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

1586  {
1587  foreach ($this->fields as $field) {
1588  if (($field->persistent) and isset($obj[$field->name])) {
1589  $field->value = $obj[$field->name];
1590  }
1591  }
1592  }

◆ loadValues()

GrimaForm::loadValues (   $obj )

load values into the form

Parameters
Object $obj array-accessible

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

1571  {
1572  foreach ($this->fields as $field) {
1573  if (isset($obj[$field->name])) {
1574  $field->value = $obj[$field->name];
1575  }
1576  }
1577  }

Member Data Documentation

◆ $action

GrimaForm::$action
protected

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

◆ $fields

GrimaForm::$fields = array()

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

◆ $title

GrimaForm::$title

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


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