You are here

function HOOK_menu_position_rule_PLUGIN_form_submit in Menu Position 6

Same name and namespace in other branches
  1. 7.2 plugins/menu_position.example_plugin.inc \HOOK_menu_position_rule_PLUGIN_form_submit()
  2. 7 plugins/menu_position.example_plugin.inc \HOOK_menu_position_rule_PLUGIN_form_submit()

Prepares the plugin's variables to be stored in the rule.

If the plugin's form elements indicate that the condition needs to be included with the rule, the submit handler must, at the very least, set: $form_state['conditions']['PLUGIN'] = array(). Optionally, the plugin can add to this array any static variables to be stored in the database with the rule configuration.

If, after this submit handler is run, the $form_state['conditions']['PLUGIN'] variables array is not set, this plugin will not be added as a condition for this rule.

Parameters

$form: A reference to the "add/edit rule" form array.

$form_state: A reference to the current form state, including submitted values.

1 string reference to 'HOOK_menu_position_rule_PLUGIN_form_submit'
HOOK_menu_position_rule_PLUGIN_form in plugins/menu_position.example_plugin.inc
Adds form elements for the PLUGIN plugin to the rule configuration form.

File

plugins/menu_position.example_plugin.inc, line 114
Provides the PLUGIN rule plugin for the Menu Position module.

Code

function HOOK_menu_position_rule_PLUGIN_form_submit(&$form, &$form_state) {
  if (!empty($form_state['values']['lolspeak'])) {

    // Check if the user has added our plugin's form elements as a condition for
    // the rule.
    if ($form_state['values']['lolspeak']) {

      // Since our form elements indicate that our plugin is to be used for this
      // rule, we need to add the appropriate variables to
      // $form_state['values']['conditions']['PLUGIN'] so that they can be
      // stored statically with the rule.
      $variables = array(
        'lolspeak' => $form_state['values']['lolspeak'],
      );
      $form_state['values']['conditions']['PLUGIN'] = $variables;
    }
  }
}