public function StepTwoForm::buildForm in TacJS 8
Same name and namespace in other branches
- 8.2 src/Form/Steps/StepTwoForm.php \Drupal\tacjs\Form\Steps\StepTwoForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ Steps/ StepTwoForm.php, line 26
Class
- StepTwoForm
- Class StepOneForm.
Namespace
Drupal\tacjs\Form\StepsCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = \Drupal::getContainer()
->get('config.factory')
->getEditable('tacjs.admin_settings_form');
$data = \Drupal::service('tacjs.settings')
->getFieldsSelects();
foreach ($data as $key => $item) {
if (!empty($item)) {
if (!(count($item) == 1 && $item[0]['value'] == 'hidden')) {
$form[$key] = [
'#type' => 'details',
'#title' => 'Configuration Global Tarte au Citron ' . $key,
];
}
foreach ($item as $k => $v) {
if ($v['value'] != 'hidden') {
$form[$key][$v['value']] = [
'#type' => 'textfield',
'#title' => $v['name'],
'#default_value' => $config
->get($v['value']),
'#description' => !empty($v['description']) ? $config
->get($v['description']) : "",
];
if (isset($v['value_'])) {
$form[$key][$v['value_']] = [
'#type' => 'textfield',
'#title' => $v['value_'],
'#default_value' => $config
->get($v['value_']),
];
}
}
}
}
}
$form['actions']['previous'] = [
'#type' => 'link',
'#title' => $this
->t('Previous'),
'#attributes' => [
'class' => [
'button',
],
],
'#weight' => 0,
'#url' => Url::fromRoute('tacjs.admin_settings_form'),
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
];
return $form;
}