You are here

function rules_forms_invoke_event in Rules Forms Support 7.2

Same name and namespace in other branches
  1. 7 rules_forms.module \rules_forms_invoke_event()

Invoke rules event of a certain type.

Parameters

string $event_type: Possible values:

  • form_built
  • form_validate
  • form_submit
  • button_ELEMENT_ID_validate
  • button_ELEMENT_ID_submit

The type of Rules Forms event being invoked.

array $form: A reference to the form array for which the event is being invoked.

array $form_state: A reference to the form state array for which the event is being invoked.

string|null $form_id: The form ID of the form for which the event is being invoked, or NULL. If NULL the form ID will be retrieved from the $form array.

See also

rules_forms_event_validate()

rules_forms_event_submit()

rules_forms_form_alter()

3 calls to rules_forms_invoke_event()
rules_forms_event_build in ./rules_forms.module
Form build handler. Stores form values and invokes the event.
rules_forms_event_submit in ./rules_forms.module
Submit handler to invoke "form submitted" events.
rules_forms_event_validate in ./rules_forms.module
Validation handler to invoke "form validate" events.

File

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

Code

function rules_forms_invoke_event($event_type, &$form, &$form_state, $form_id = NULL) {
  if (empty($form_id)) {
    $form_id = $form['form_id']['#value'];
  }

  // Wrap form data as an ArrayObject for passage to Rules.
  rules_invoke_event("rules_forms_{$form_id}_{$event_type}", new EntityMetadataArrayObject($form), new EntityMetadataArrayObject($form_state));
}