class StepIndicator in Simple multi step form 8.x
Same name and namespace in other branches
- 8 src/StepIndicator.php \Drupal\simple_multistep\StepIndicator
Class StepIndicator.
@package Drupal\simple_multistep
Hierarchy
- class \Drupal\simple_multistep\FormStep
- class \Drupal\simple_multistep\StepIndicator
Expanded class hierarchy of StepIndicator
File
- src/
StepIndicator.php, line 12
Namespace
Drupal\simple_multistepView source
class StepIndicator 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;
}
/**
* Create indicator.
*/
private function createIndicator() {
$steps_label = array(
'#type' => 'item',
'#weight' => -1,
);
$markup = '<div class="multi-steps-label">';
foreach ($this->steps as $step_number => $step) {
$format_settings = $step->format_settings;
if ($format_settings['show_step_title']) {
$active = $this->currentStep == $step_number ? ' active' : '';
$markup .= '<div class="step-label' . $active . '">';
$markup .= $step->label;
$markup .= '</div>';
}
}
$markup .= '</div>';
$steps_label['#markup'] = $markup;
return $steps_label;
}
/**
* Get Indicator.
*
* @param array $form
* Reference to form.
*/
public function render(array &$form) {
$form['steps_label'] = $this
->createIndicator();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
StepIndicator:: |
private | function | Create indicator. | |
StepIndicator:: |
public | function | Get Indicator. | |
StepIndicator:: |
public | function |
Constructor. Overrides FormStep:: |