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