You are here

function _webform_conditional_action_expand in Webform 7.4

Helper. Generate form elements for one action.

1 call to _webform_conditional_action_expand()
_webform_conditional_expand in includes/webform.conditionals.inc
Form API #process function to expand a webform conditional element.

File

includes/webform.conditionals.inc, line 548
Form elements and menu callbacks to provide conditional handling in Webform.

Code

function _webform_conditional_action_expand($element, $aid, $action) {
  return array(
    'target_type' => array(
      '#type' => 'value',
      '#value' => $action['target_type'],
    ),
    'target' => array(
      '#type' => 'select',
      '#title' => t('Target'),
      '#options' => $element['#targets'],
      '#default_value' => $action['target'],
    ),
    'invert' => array(
      '#type' => 'select',
      '#title' => t("Is/Isn't"),
      '#options' => array(
        '0' => t('is'),
        '1' => t("isn't"),
      ),
      '#default_value' => $action['invert'],
    ),
    'action' => array(
      '#type' => 'select',
      '#title' => t('Action'),
      '#options' => $element['#actions'],
      '#default_value' => $action['action'],
    ),
    'argument' => array(
      '#type' => 'textfield',
      '#title' => t('Argument'),
      '#size' => 20,
      '#maxlength' => NULL,
      '#default_value' => $action['argument'],
    ),
    'add' => array(
      '#type' => 'submit',
      '#value' => t('+'),
      '#submit' => array(
        'webform_conditional_element_add',
      ),
      '#name' => implode('_', $element['#parents']) . '_actions_' . $aid . '_add',
      '#attributes' => array(
        'class' => array(
          'webform-conditional-action-add',
        ),
      ),
      '#ajax' => array(
        'progress' => 'none',
        'callback' => 'webform_conditional_element_ajax',
        'wrapper' => $element['#wrapper_id'],
        'event' => 'click',
      ),
    ),
    'remove' => array(
      '#type' => 'submit',
      '#value' => t('-'),
      '#submit' => array(
        'webform_conditional_element_remove',
      ),
      '#name' => implode('_', $element['#parents']) . '_actions_' . $aid . '_remove',
      '#attributes' => array(
        'class' => array(
          'webform-conditional-action-remove',
        ),
      ),
      '#ajax' => array(
        'progress' => 'none',
        'callback' => 'webform_conditional_element_ajax',
        'wrapper' => $element['#wrapper_id'],
        'event' => 'click',
      ),
    ),
  );
}