July 2017
Intermediate to advanced
456 pages
11h 32m
English
The structure of the Form API elements returned by the buildForm function is almost completely the same as it was in Drupal 7. The attributes for the form elements are generally identical. One parameter that has changed is #attached, which is used to add libraries, arbitrary JavaScript, HTML head links and tags, and so on. For example, if you wanted to ensure that the backbone was loaded with the configuration form earlier, you would attach it to a form element like this:
public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('mastering_drupal_8.settings'); $form['name'] = array( '#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $config->get('name'), ...Read now
Unlock full access