public function EditFieldForm::submitForm in Form Defaults 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ EditFieldForm.php, line 159
Class
- EditFieldForm
- @class EditFieldForm
Namespace
Drupal\Formdefaults\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
$formid = $form_values['formid'];
$fieldname = $form_values['fieldname'];
$formarray = formdefaults_getform($formid);
$baseform = $formarray;
// set the form values
if ($_POST['op'] == 'Reset') {
unset($formarray[$fieldname]);
}
else {
if ($form_values['type'] == 'markup') {
$formarray[$fieldname]['value'] = $form_values['value']['value'];
$formarray[$fieldname]['input_format'] = $form_values['value']['format'];
}
else {
$formarray[$fieldname]['title'] = $form_values['title'];
$formarray[$fieldname]['description'] = $form_values['description'];
}
if (@$form_values['collapsible'] === '') {
unset($formarray[$fieldname]['collapsible']);
}
else {
$formarray[$fieldname]['collapsible'] = @$form_values['collapsible'];
}
if (@$form_values['collapsed'] === '') {
unset($formarray[$fieldname]['collapsed']);
}
else {
$formarray[$fieldname]['collapsed'] = @$form_values['collapsed'];
}
$formarray[$fieldname]['hide_it'] = $form_values['hide_it'];
$formarray[$fieldname]['weight'] = $form_values['weight'];
$formarray[$fieldname]['type'] = $form_values['type'];
}
$helper = new FormDefaultsHelper();
$helper
->saveForm($formid, $formarray);
$form_state
->setRedirect('formdefaults.edit_w_formid', array(
'formid' => $formid,
));
}