You are here

function rules_admin_form_edit_condition in Rules 6

Returns the edit form for a condition

File

rules_admin/rules_admin.rule_forms.inc, line 506

Code

function rules_admin_form_edit_condition(&$form_state, $element) {
  $label = rules_get_element_label($element);
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#description' => t('Customize the label for this condition.'),
    '#default_value' => isset($form_state['values']['label']) ? $form_state['values']['label'] : $label,
    '#required' => TRUE,
    '#weight' => -5,
  );
  if ($label) {
    drupal_set_title(t('Editing condition %label', array(
      '%label' => $label,
    )));
  }
  $form['negate'] = array(
    '#title' => t('Negate'),
    '#type' => 'checkbox',
    '#description' => t('If checked, the condition returns TRUE, if it evaluates to FALSE.'),
    '#default_value' => isset($element['#negate']) ? $element['#negate'] : 0,
  );
  $form['weight'] = array(
    '#title' => t('Weight'),
    '#type' => 'weight',
    '#description' => t('Adjust the weight to customize the ordering of conditions.'),
    '#default_value' => isset($element['#weight']) ? $element['#weight'] : 0,
    '#weight' => 8,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#weight' => 10,
    '#value' => t('Save'),
    '#submit' => array(
      'rules_admin_form_edit_condition_submit',
      'rules_admin_form_edit_save',
    ),
  );
  if (isset($element['#id'])) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#weight' => 11,
      '#value' => t('Delete'),
      '#submit' => array(
        'rules_admin_form_edit_delete_submit',
      ),
    );
  }
  else {

    // For conditions we set the id to 0, so new variables of this rules aren't shown
    // in argument mapping forms.
    $element['#id'] = 0;
  }
  rules_admin_element_help($form, $element);
  rules_admin_default_argument_form($form, $form_state, $element);
  rules_admin_element_alter_form($form, $form_state, $element);
  return $form;
}