dcat-8.x-1.x-dev/src/Form/DcatDistributionForm.php
src/Form/DcatDistributionForm.php
<?php
namespace Drupal\dcat\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for Distribution edit forms.
*
* @ingroup dcat
*/
class DcatDistributionForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\dcat\Entity\DcatDistribution */
$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_set_message($this->t('Created the %label Distribution.', [
'%label' => $entity->label(),
]));
break;
default:
drupal_set_message($this->t('Saved the %label Distribution.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.dcat_distribution.canonical', ['dcat_distribution' => $entity->id()]);
}
}
