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

Wrapper for each field in a form, keeping track of its properties. More...

Public Member Functions

 booly ($str, $default='undefined')
 return boolean meaning of common terms ("true","on","1","yes") More...
 
 __construct ($field)
 create a new GrimaFormField More...
 

Public Attributes

 $value
 
 $name
 
 $label
 
 $placeholder
 
 $required
 
 $persistent
 
 $visible
 
 $rows
 
 $error_condition = ""
 
 $error_message = ""
 

Protected Attributes

 $autocomplete
 
 $highlight
 

Detailed Description

Wrapper for each field in a form, keeping track of its properties.

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

Constructor & Destructor Documentation

◆ __construct()

GrimaFormField::__construct (   $field)

create a new GrimaFormField

Parameters
DomNode$fieldwith attributes for all properties

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

References booly().

1543  {
1544  $this->name = $field->getAttribute('name');
1545  $this->label = $field->getAttribute('label');
1546  $this->placeholder = $field->getAttribute('placeholder');
1547  $this->rows = $field->getAttribute('rows');
1548  $this->type = $field->getAttribute('type');
1549  if (!$this->type) {
1550  $this->type = 'input';
1551  }
1552  $this->required = $this->booly($field->getAttribute('required'),true);
1553  $this->persistent = $this->booly($field->getAttribute('persistent'),false);
1554  $this->autocomplete = $this->booly($field->getAttribute('autocomplete'),false);
1555  $this->visible = $this->booly($field->getAttribute('visible'),true);
1556  $this->options = array();
1557  foreach ($field->getElementsByTagName("option") as $option) {
1558  $this->options[] = $option->ownerDocument->saveXML( $option );
1559  }
1560  }
booly($str, $default='undefined')
return boolean meaning of common terms ("true","on","1","yes")
Definition: grima-lib.php:1517

Member Function Documentation

◆ booly()

GrimaFormField::booly (   $str,
  $default = 'undefined' 
)

return boolean meaning of common terms ("true","on","1","yes")

Parameters
string$strterm to interpret
$defaultif it is not found
Returns
boolean true or false

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

Referenced by __construct().

1517  {
1518  switch(strtolower($str)) {
1519  case 'true':
1520  case 't':
1521  case 'on':
1522  case 'yes':
1523  case '1':
1524  return true;
1525  case 'false':
1526  case 'f':
1527  case 'off':
1528  case 'no':
1529  case '0':
1530  return false;
1531  default:
1532  return $default;
1533  }
1534  }

Member Data Documentation

◆ $autocomplete

GrimaFormField::$autocomplete
protected

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

◆ $error_condition

GrimaFormField::$error_condition = ""

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

◆ $error_message

GrimaFormField::$error_message = ""

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

◆ $highlight

GrimaFormField::$highlight
protected

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

◆ $label

GrimaFormField::$label

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

◆ $name

GrimaFormField::$name

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

◆ $persistent

GrimaFormField::$persistent

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

◆ $placeholder

GrimaFormField::$placeholder

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

◆ $required

GrimaFormField::$required

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

◆ $rows

GrimaFormField::$rows

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

◆ $value

GrimaFormField::$value

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

◆ $visible

GrimaFormField::$visible

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


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