public function ColorsSettingsForm::buildForm in Colors 8
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 ConfigFormBase::buildForm
File
- src/
Form/ ColorsSettingsForm.php, line 79
Class
- ColorsSettingsForm
- Configure color settings.
Namespace
Drupal\colors\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Color picker.
$form = colors_load_colorpicker();
$form['#attached'] = array(
'library' => array(
'colors/colors',
),
);
$entity = $this
->getEntityFromRoute(\Drupal::routeMatch());
$plugins = \Drupal::service('plugin.manager.colors')
->getDefinitions();
$plugin = !empty($entity) ? $plugins[$entity] : NULL;
// Global settings tab.
if (!$plugin) {
$this
->getDefaultFormElements($form);
}
else {
$this
->getFormElements($form, $entity);
}
return parent::buildForm($form, $form_state);
}