You are here

function _rules_forms_get_element in Rules Forms Support 7

Helper function to extract a reference to a form element by a given name.

Parameters

mixed $form: A reference to the form from which the element is to be returned.

string $element_id: An element ID that indicates the element's position in the $form array by keys separated by colons (:).

Return value

array A reference to the form element that can be altered directly.

17 calls to _rules_forms_get_element()
RulesFormsAPITestCase::testGetElement in ./rules_forms.test
Tests _rules_forms_get_element().
rules_forms_action_set_access in includes/rules_forms.eval.inc
Action: Hide a form element.
rules_forms_action_set_default in includes/rules_forms.eval.inc
Action: Set the default value of a form element.
rules_forms_action_set_description in includes/rules_forms.eval.inc
Action: Set the description of a form element.
rules_forms_action_set_disabled in includes/rules_forms.eval.inc
Action: Disable a form element.

... See full list

File

./rules_forms.module, line 457
Rules Forms Support provides events, conditions, and actions for site forms.

Code

function &_rules_forms_get_element(&$form, $element_id) {

  // Get the element key after the first colon.
  $element_id = substr($element_id, strpos($element_id, ':') + 1);
  $names = explode(':', $element_id);
  $element =& $form;
  foreach ($names as $name) {
    if (isset($element[$name])) {
      $element =& $element[$name];
    }
  }
  return $element;
}