You are here

function rules_forms_condition_element_is_empty_value in Rules Forms Support 7

Condition: Checks if the element is empty.

Parameters

mixed $form: A reference to the form array of the form for which the event was triggered.

mixed $form_state: A reference to the form state array of the form for which the event was triggered.

string $element: The element ID of the element being checked in the form of element_type:element_id.

Return value

bool Indicates whether the indicated element is empty or not.

1 string reference to 'rules_forms_condition_element_is_empty_value'
rules_forms_rules_condition_info in ./rules_forms.rules.inc
Implements hook_rules_condition_info().

File

includes/rules_forms.eval.inc, line 160
Evaluation functions for Rules Forms module.

Code

function rules_forms_condition_element_is_empty_value($form, $form_state, $element) {
  list(, $element_name, ) = explode(':', $element);
  if (isset($form_state['values']) && isset($form_state['values'][$element_name])) {
    $element_value = $form_state['values'][$element_name];

    // For cases when the element is a field, not a property.
    while (is_array($element_value)) {
      $element_value = reset($element_value);
    }
    if (!empty($element_value)) {
      return FALSE;
    }
  }
  return TRUE;
}