You are here

function rules_forms_condition_button_clicked in Rules Forms Support 7

Same name and namespace in other branches
  1. 7.2 includes/rules_forms.eval.inc \rules_forms_condition_button_clicked()

Condition: Form button was clicked.

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 button was clicked.

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

File

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

Code

function rules_forms_condition_button_clicked($form, $form_state, $element) {
  if (isset($form_state['triggering_element'])) {
    $button = $form_state['triggering_element'];
    $form_element = _rules_forms_get_element($form, $element);
    if (isset($form_element['#name']) && isset($button['#name'])) {
      return $form_element['#name'] === $button['#name'];
    }
    elseif (isset($form_element['#value']) && isset($button['#value'])) {
      return $form_element['#value'] === $button['#value'];
    }
  }
  return FALSE;
}