Back to SubformField class

Method setup

public bool
setup
(\SimpleXMLElement $element, mixed $value, mixed $group = null)
Method to attach a Form object to the field.
Parameters
  • \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
  • mixed $value The form field value to validate.
  • string $group The field name group control value.
Returns
  • bool True on success.
Since
  • 3.6
Class: SubformField
Project: Joomla

Method setup - Source code

/**
 * Method to attach a Form object to the field.
 *
 * @param   \SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
 * @param   mixed              $value    The form field value to validate.
 * @param   string             $group    The field name group control value.
 *
 * @return  boolean  True on success.
 *
 * @since   3.6
 */
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
    if (!parent::setup($element, $value, $group)) {
        return false;
    }
    foreach (array('formsource', 'min', 'max', 'layout', 'groupByFieldset', 'buttons') as $attributeName) {
        $this->__set($attributeName, $element[$attributeName]);
    }
    if ((string) $element['fieldname']) {
        $this->__set('fieldname', $element['fieldname']);
    }
    if ($this->value && \is_string($this->value)) {
        // Guess here is the JSON string from 'default' attribute
        $this->value = json_decode($this->value, true);
    }
    if (!$this->formsource && $element->form) {
        // Set the formsource parameter from the content of the node
        $this->formsource = $element->form->saveXML();
    }
    return true;
}