public function EditorIconDialog::submitForm in Font Awesome Icons 8
Same name and namespace in other branches
- 8.2 src/Form/EditorIconDialog.php \Drupal\fontawesome\Form\EditorIconDialog::submitForm()
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/ EditorIconDialog.php, line 264
Class
- EditorIconDialog
- Provides a Font Awesome icon dialog for text editors.
Namespace
Drupal\fontawesome\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
if ($form_state
->getErrors()) {
unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -10,
];
$response
->addCommand(new HtmlCommand('#fontawesome-icon-dialog-form', $form));
}
else {
$form_values = $form_state
->getValues();
$icon_attributes = [
'attributes' => [
'class' => $this
->buildClassString([
$form_values['icon'],
] + $form_values['settings']),
],
];
$response
->addCommand(new EditorDialogSave($icon_attributes));
$response
->addCommand(new CloseModalDialogCommand());
}
return $response;
}