class WebformStepsButtonBuilder in Webform steps 7
Hierarchy
- class \WebformStepsButtonBuilder
Expanded class hierarchy of WebformStepsButtonBuilder
File
- ./
webform_steps.module, line 90
View source
class WebformStepsButtonBuilder {
protected $default = array();
protected $current = 0;
protected $finished = 0;
public function __construct($current, $finished) {
$this->current = $current;
$this->finished = $finished;
$this->default = array(
'#type' => 'submit',
'#attributes' => array(
'class' => array(
'step-button',
),
),
'#name' => 'step-btn',
);
}
public function activateAjax(&$form_state, &$form) {
// generate wrapper id like in webform_ajax.module
// we have to create it on our own because webform_ajax runs after us
$wrapper = '';
if (isset($form_state['values']['webform_ajax_wrapper_id'])) {
$wrapper = $form_state['values']['webform_ajax_wrapper_id'];
}
elseif (isset($form['#node']->webform['webform_ajax_wrapper_id'])) {
$wrapper = $form['#node']->webform['webform_ajax_wrapper_id'];
}
else {
// At last, generate a unique ID.
$wrapper = 'webform-ajax-wrapper-' . $form['#node']->nid;
}
$this->default['#ajax'] = array(
'effect' => 'none',
'callback' => 'webform_ajax_callback',
'wrapper' => $wrapper,
'progress' => array(
'message' => '',
'type' => 'none',
),
);
}
public function buildButton($i, $title) {
$button = $this->default;
$wrapper_classes = array();
if ($i < $this->current) {
$wrapper_classes[] = 'previous';
$button['#validate'] = array();
$button['#attributes']['formnovalidate'] = 'formnovalidate';
}
if ($i === $this->current) {
$wrapper_classes[] = 'current';
}
if ($i == 1) {
$wrapper_classes[] = 'first';
}
if ($i > $this->finished + 1) {
if ($i == $this->finished + 2) {
$wrapper_classes[] = 'first-disabled';
}
$wrapper_classes[] = 'disabled';
$button['#attributes']['class'][] = 'disabled';
$button['#attributes']['disabled'] = 'disabled';
}
if (isset($button['#ajax'])) {
$button['#id'] = drupal_html_id('edit-webform-ajax-btn-' . $i);
}
$button += array(
'#value' => $title,
'#page' => $i,
'#wrapper_classes' => $wrapper_classes,
);
return $button;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformStepsButtonBuilder:: |
protected | property | ||
WebformStepsButtonBuilder:: |
protected | property | ||
WebformStepsButtonBuilder:: |
protected | property | ||
WebformStepsButtonBuilder:: |
public | function | ||
WebformStepsButtonBuilder:: |
public | function | ||
WebformStepsButtonBuilder:: |
public | function |