public function FontDisplayForm::save in @font-your-face 8.3
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
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
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- src/
Form/ FontDisplayForm.php, line 161
Class
- FontDisplayForm
- Form to display fonts.
Namespace
Drupal\fontyourface\FormCode
public function save(array $form, FormStateInterface $form_state) {
$font_display = $this->entity;
$preset_selectors = $form_state
->getValue('preset_selectors');
$selectors = $form_state
->getValue('selectors');
$font_display
->setSelectors($preset_selectors);
if ($preset_selectors == 'other') {
$font_display
->setSelectors($selectors);
}
$status = $font_display
->save();
switch ($status) {
case SAVED_NEW:
\Drupal::messenger()
->addMessage($this
->t('Created the %label Font display.', [
'%label' => $font_display
->label(),
]));
break;
default:
\Drupal::messenger()
->addMessage($this
->t('Saved the %label Font display.', [
'%label' => $font_display
->label(),
]));
}
fontyourface_save_and_generate_font_display_css($font_display);
drupal_flush_all_caches();
$form_state
->setRedirectUrl($font_display
->toUrl('collection'));
}