SliderForm.php in Image sliders 8
Namespace
Drupal\image_slider\FormFile
src/Form/SliderForm.phpView source
<?php
namespace Drupal\image_slider\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Language\Language;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for the image_slider entity edit forms.
*
* @ingroup image_slider
*/
class SliderForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\image_slider\Entity\Slider */
$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.image_slider.collection');
$entity = $this
->getEntity();
$entity
->save();
}
}
Classes
Name | Description |
---|---|
SliderForm | Form controller for the image_slider entity edit forms. |