public function SlideBaseForm::buildForm in Drupal Slider 8
Same name and namespace in other branches
- 8.2 src/Form/SlideBaseForm.php \Drupal\drupal_slider\Form\SlideBaseForm::buildForm()
Function buildForm.
Overrides EntityForm::buildForm
2 calls to SlideBaseForm::buildForm()
- SlideAddForm::buildForm in src/
Form/ SlideAddForm.php - Function buildForm.
- SlideEditForm::buildForm in src/
Form/ SlideEditForm.php - Function buildForm.
2 methods override SlideBaseForm::buildForm()
- SlideAddForm::buildForm in src/
Form/ SlideAddForm.php - Function buildForm.
- SlideEditForm::buildForm in src/
Form/ SlideEditForm.php - Function buildForm.
File
- src/
Form/ SlideBaseForm.php, line 45
Class
- SlideBaseForm
- Class SlideBaseForm.
Namespace
Drupal\drupal_slider\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Get anything we need from the base class.
$form = parent::buildForm($form, $form_state);
$slide = $this->entity;
$form['#tree'] = TRUE;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Slide Name'),
'#maxlength' => 255,
'#default_value' => $slide
->label(),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#title' => $this
->t('Machine name'),
'#default_value' => $slide
->id(),
'#machine_name' => [
'exists' => [
$this,
'exists',
],
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'error' => 'The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".',
],
'#disabled' => !$slide
->isNew(),
];
$form['layers'] = [
'#type' => 'table',
'#header' => [
$this
->t('Layer number'),
$this
->t('Attributes'),
$this
->t('Weight'),
],
'#empty' => $this
->t('Sorry, There are no layers!'),
'#prefix' => '<div id="names-fieldset-wrapper">',
'#suffix' => '</div>',
'#tabledrag' => [
[
'action' => 'order',
'relationship' => 'sibling',
'group' => 'table-sort-weight',
],
],
];
return $form;
}