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