-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvertiserForm.php
More file actions
42 lines (35 loc) · 1.02 KB
/
AdvertiserForm.php
File metadata and controls
42 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Drupal\drupal10_custom_module\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Language\Language;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for the advertiser entity edit forms.
*
* @ingroup advertiser
*/
class AdvertiserForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/** @var \Drupal\example_module\Entity\Advertiser $entity */
$form = parent::buildForm($form, $form_state);
$entity = $this->entity;
$form['langcode'] = [
'#title' => $this->t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$form_state->setRedirect('entity.advertiser.collection');
$entity = $this->getEntity();
$entity->save();
}
}