You are here

function rules_admin_form_add_op in Rules 6

Indenting a condition Adds a logical operation and place the given condition element inside. We automatically determine which operation is to be added.

File

rules_admin/rules_admin.rule_forms.inc, line 363

Code

function rules_admin_form_add_op(&$form_state, $element, $parent) {
  $parent_ref =& $form_state['proxy']
    ->get_element($form_state['parent_id']);

  //determine the appropriate operation and apply it
  $op = rules_admin_determine_operation($form_state['proxy'], $form_state['parent_id']);
  if (isset($parent_ref['#weight'])) {
    $weight = $parent_ref['#weight'];
    unset($parent_ref['#weight']);
  }
  $parent_ref = rules_configure($op, $parent_ref);
  if (isset($weight)) {

    //apply the weight of the element to the op
    $parent_ref['#weight'] = $weight;
  }

  //and save
  $form_state['proxy']
    ->save_changes();
  drupal_goto(RULES_ADMIN_RULE_PATH . '/' . $form_state['proxy']
    ->get_rule_name());
}