51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Drupal\zencrm_entities\Form;
|
|
|
|
use Drupal\Core\Entity\ContentEntityForm;
|
|
use Drupal\Core\Form\FormStateInterface;
|
|
|
|
/**
|
|
* Form controller for Activity edit forms.
|
|
*
|
|
* @ingroup zencrm_entities
|
|
*/
|
|
class ActivityForm extends ContentEntityForm {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
|
/* @var $entity \Drupal\zencrm_entities\Entity\Activity */
|
|
$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 Activity.', [
|
|
'%label' => $entity->label(),
|
|
]));
|
|
break;
|
|
|
|
default:
|
|
drupal_set_message($this->t('Saved the %label Activity.', [
|
|
'%label' => $entity->label(),
|
|
]));
|
|
}
|
|
$form_state->setRedirect('entity.activity.canonical', ['activity' => $entity->id()]);
|
|
}
|
|
|
|
}
|