public function CreateTemplateForm::buildForm in GatherContent 8.5
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- gathercontent_upload_ui/
src/ Form/ CreateTemplateForm.php, line 74
Class
Namespace
Drupal\gathercontent_upload_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['gathercontent']['entity_type'] = [
'#type' => 'select',
'#title' => $this
->t('Drupal entity type'),
'#options' => $this
->getEntityTypes(),
'#required' => TRUE,
'#wrapper_attributes' => [
'class' => [
'inline-label',
],
],
'#ajax' => [
'callback' => '::getContentTypes',
'wrapper' => 'content-type-select',
'method' => 'replace',
'effect' => 'fade',
],
'#default_value' => $form_state
->getValue('entity_type'),
];
$form['gathercontent']['content_type'] = [
'#type' => 'select',
'#title' => $this
->t('Drupal bundle type'),
'#options' => $form_state
->getValue('entity_type') ? $this
->getBundles($form_state
->getValue('entity_type')) : [],
'#required' => TRUE,
'#wrapper_attributes' => [
'class' => [
'inline-label',
],
],
'#prefix' => '<div id="content-type-select">',
'#suffix' => '</div>',
];
$form['gathercontent']['project_id'] = [
'#type' => 'select',
'#title' => $this
->t('Project ID'),
'#options' => $this
->getProjects(),
'#required' => TRUE,
'#wrapper_attributes' => [
'class' => [
'inline-label',
],
],
'#default_value' => $form_state
->getValue('project_id'),
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Create'),
'#button_type' => 'primary',
'#weight' => 10,
];
return $form;
}