protected function PanelizerWizardBase::customizeForm in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Wizard/PanelizerWizardBase.php \Drupal\panelizer\Wizard\PanelizerWizardBase::customizeForm()
- 8.4 src/Wizard/PanelizerWizardBase.php \Drupal\panelizer\Wizard\PanelizerWizardBase::customizeForm()
Helper function for generating default form elements.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
array
Overrides FormWizardBase::customizeForm
1 call to PanelizerWizardBase::customizeForm()
- PanelizerEditWizard::customizeForm in src/
Wizard/ PanelizerEditWizard.php - Helper function for generating default form elements.
1 method overrides PanelizerWizardBase::customizeForm()
- PanelizerEditWizard::customizeForm in src/
Wizard/ PanelizerEditWizard.php - Helper function for generating default form elements.
File
- src/
Wizard/ PanelizerWizardBase.php, line 20
Class
Namespace
Drupal\panelizer\WizardCode
protected function customizeForm(array $form, FormStateInterface $form_state) {
$form = parent::customizeForm($form, $form_state);
$cached_values = $form_state
->getTemporaryValue('wizard');
// Get the current form operation.
$operation = $this
->getOperation($cached_values);
$operations = $this
->getOperations($cached_values);
$default_operation = reset($operations);
// Get the machine name. There are two ways we can get this data.
$storage = $form_state
->getStorage();
$prefix = isset($storage['machine_name_prefix']) ? $storage['machine_name_prefix'] : $form_state
->getTemporaryValue('wizard')['id'];
if ($operation['form'] == $default_operation['form']) {
// Create id and label form elements.
$form['name'] = [
'#type' => 'fieldset',
'#attributes' => [
'class' => [
'fieldset-no-legend',
],
],
'#title' => $this
->getWizardLabel(),
];
$form['name']['label'] = [
'#type' => 'textfield',
'#title' => $this
->getMachineLabel(),
'#required' => TRUE,
'#size' => 32,
'#default_value' => !empty($cached_values['label']) ? $cached_values['label'] : '',
'#maxlength' => 255,
'#disabled' => !empty($cached_values['label']),
];
$form['name']['id'] = [
'#type' => 'machine_name',
'#maxlength' => 128,
'#machine_name' => [
'source' => [
'name',
'label',
],
'exists' => $this
->exists(),
'prefix' => $prefix,
],
'#description' => $this
->t('A unique machine-readable name for this display. It must only contain lowercase letters, numbers, and underscores.'),
'#default_value' => !empty($cached_values['id']) ? $cached_values['id'] : '',
'#disabled' => !empty($cached_values['id']),
];
}
return $form;
}