Branch 4.0.x-roblib is currently the same as Drupals main branch but with our patches applied.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
1.2 KiB

<?php
namespace Drupal\reserve\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for Reservation Category edit forms.
*
* @ingroup reserve
*/
class ReserveCategoryForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\reserve\Entity\ReserveCategory */
$form = parent::buildForm($form, $form_state);
$entity = $this->entity;
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = &$this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
\Drupal::messenger()->addStatus($this->t('Created the %label Reservation Category.', [
'%label' => $entity->label(),
]));
break;
default:
\Drupal::messenger()->addStatus($this->t('Saved the %label Reservation Category.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.reserve_category.canonical', ['reserve_category' => $entity->id()]);
}
}