You are here

public function ImportCourseForm::buildForm in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/ImportCourseForm.php \Drupal\opigno_module\Form\ImportCourseForm::buildForm()

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

src/Form/ImportCourseForm.php, line 37

Class

ImportCourseForm
Import Course form.

Namespace

Drupal\opigno_module\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $mode = NULL) {
  $form['course_opi'] = [
    '#title' => $this
      ->t('Course'),
    '#type' => 'file',
    '#description' => $this
      ->t('Here you can import course. Allowed extension: opi'),
  ];
  $ajax_id = "ajax-form-entity-external-package";
  $form['#attributes']['class'][] = $ajax_id;
  $form['#attached']['library'][] = 'opigno_module/ajax_form';
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Import'),
  ];
  return $form;
}