You are here

public function ContentBuilderForm::buildForm in Schema.org configuration tool (RDF UI) 8

@inheritdoc

Overrides FormInterface::buildForm

File

rdf_builder/src/Form/ContentBuilderForm.php, line 109

Class

ContentBuilderForm

Namespace

Drupal\rdf_builder\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Display page 2 if $form_state->get('page_num') == 2.
  if ($form_state
    ->has('page_num') && $form_state
    ->get('page_num') == 2) {
    return $this
      ->buildFormPageTwo($form, $form_state);
  }

  // Otherwise build page 1.
  $form_state
    ->set('page_num', 1);
  $form['#title'] = $this
    ->t('Content types');
  $form['description'] = array(
    '#type' => 'item',
    '#title' => $this
      ->t('Create a content type by importing Schema.Org entity type.'),
  );
  $form['rdf-type'] = array(
    '#title' => $this
      ->t('Type'),
    '#id' => 'rdf-predicate',
    '#type' => 'select',
    '#required' => TRUE,
    '#options' => $this->converter
      ->getListTypes(),
    '#empty_option' => '',
    '#default_value' => $form_state
      ->getValue('rdf-type', ''),
    '#attached' => array(
      'library' => array(
        'rdfui/drupal.rdfui.autocomplete',
      ),
    ),
    '#description' => $this
      ->t('Specify the type you want to associated to this content type e.g. Article, Blog, etc.'),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['next'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Next >>'),
    '#button_type' => 'primary',
    '#submit' => array(
      array(
        $this,
        'nextSubmit',
      ),
    ),
    '#validate' => array(
      array(
        $this,
        'nextValidate',
      ),
    ),
  );
  return $form;
}