You are here

function menu_position_menu_position_rule_content_type_form_submit in Menu Position 7

Same name and namespace in other branches
  1. 6 plugins/menu_position.content_type.inc \menu_position_menu_position_rule_content_type_form_submit()
  2. 7.2 plugins/menu_position.content_type.inc \menu_position_menu_position_rule_content_type_form_submit()

Prepares the "content type" variables to be stored in the 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 'menu_position_menu_position_rule_content_type_form_submit'
menu_position_menu_position_rule_content_type_form in plugins/menu_position.content_type.inc
Adds form elements for the "content type" plugin to the rule configuration form.

File

plugins/menu_position.content_type.inc, line 64
Provides the "Content type" rule plugin for the Menu Position module.

Code

function menu_position_menu_position_rule_content_type_form_submit(&$form, &$form_state) {

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

    // Remove any 0 valued options.
    foreach ($form_state['values']['content_type'] as $key => $value) {
      if ($value === 0) {
        unset($form_state['values']['content_type'][$key]);
      }
    }

    // Determine if any checkboxes were on.
    if (!empty($form_state['values']['content_type'])) {

      // Add this plugin's variables to the rule.
      $variables = array(
        'content_type' => $form_state['values']['content_type'],
      );
      $form_state['values']['conditions']['content_type'] = $variables;
    }
  }
}