class FormButton in Simple multi step form 8.x
Same name and namespace in other branches
- 8 src/FormButton.php \Drupal\simple_multistep\FormButton
Class FormButton.
@package Drupal\simple_multistep
Hierarchy
- class \Drupal\simple_multistep\FormStep
- class \Drupal\simple_multistep\FormButton
Expanded class hierarchy of FormButton
File
- src/
FormButton.php, line 12
Namespace
Drupal\simple_multistepView source
class FormButton extends FormStep {
/**
* Constructor.
*
* @param array $form
* Form settings.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Form state object.
* @param int $current_step
* Current step.
*/
public function __construct(array $form, FormStateInterface $form_state, $current_step) {
parent::__construct($form, $form_state);
$this->currentStep = $current_step;
$this
->fetchStepSettings();
}
/**
* Show back button.
*
* @param array $form
* Reference to form array.
*/
private function showBackButton(array &$form) {
$step_format_settings = $this->stepSettings->format_settings;
if ($this->currentStep != 0 && !empty($step_format_settings['back_button_show'])) {
// Add back button and remove validation.
$form['actions']['back_button'] = array(
'#type' => 'button',
'#value' => $step_format_settings['back_button_text'],
'#validate' => array(
'simple_multistep_register_back',
),
'#submit' => array(),
'#limit_validation_errors' => array(),
);
}
}
/**
* Show next button.
*
* @param array $form
* Reference to form array.
*/
private function showNextButton(array &$form) {
$step_format_settings = $this->stepSettings->format_settings;
if (count($this->steps) - 1 != $this->currentStep) {
$form['actions']['next'] = array(
'#type' => 'button',
'#value' => $step_format_settings['next_button_text'],
'#validate' => array(
'simple_multistep_register_next_step',
),
'#submit' => array(),
);
$form['actions']['submit']['#access'] = FALSE;
}
else {
$form['actions']['submit']['#access'] = TRUE;
$form['#validate'][] = 'simple_multistep_multistep_validate';
}
}
/**
* Render form button.
*
* @param array $form
* Form array.
*/
public function render(array &$form) {
$this
->showNextButton($form);
$this
->showBackButton($form);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormButton:: |
public | function | Render form button. | |
FormButton:: |
private | function | Show back button. | |
FormButton:: |
private | function | Show next button. | |
FormButton:: |
public | function |
Constructor. Overrides FormStep:: |
|
FormStep:: |
protected | property | Current step. | |
FormStep:: |
protected | property | Form array. | |
FormStep:: |
protected | property | Form state. | |
FormStep:: |
protected | property | Steps. | |
FormStep:: |
protected | property | Step settings. | |
FormStep:: |
protected | function | Get array with form steps. | |
FormStep:: |
protected | function | Fetch form step settings by current step. | |
FormStep:: |
protected | function | Get all child from field group. | |
FormStep:: |
public | function | Get current step. | |
FormStep:: |
public | function | Get all form steps. | |
FormStep:: |
public | function | Get form step settings. | |
FormStep:: |
public | function | Get submission values for current step. | |
FormStep:: |
public | function | Increase step number. | |
FormStep:: |
public | function | Reduce step number. | |
FormStep:: |
protected | function | Set current step. | |
FormStep:: |
public | function | Set $form_state. | |
FormStep:: |
protected static | function | Sort array by object property. | |
FormStep:: |
public | function | Update step info. |