/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { $definitions = $this->currencyExchangeRateProviderManager->getDefinitions(); $configuration = $this->exchangeRateProvider->loadConfiguration(); $form['exchange_rate_providers'] = array('#header' => array($this->t('Title'), $this->t('Enabled'), $this->t('Weight'), $this->t('Operations')), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'form-select')), '#type' => 'table'); $weight = 0; foreach ($configuration as $plugin_id => $enabled) { $weight++; $plugin_definition = $definitions[$plugin_id]; $form['exchange_rate_providers'][$plugin_id] = array('#attributes' => array('class' => array('draggable')), '#weight' => $weight); $form['exchange_rate_providers'][$plugin_id]['label'] = array('#description' => $plugin_definition['description'], '#markup' => $plugin_definition['label'], '#title' => $this->t('Title'), '#title_display' => 'invisible', '#type' => 'item'); $form['exchange_rate_providers'][$plugin_id]['enabled'] = array('#default_value' => $enabled, '#title' => $this->t('Enabled'), '#title_display' => 'invisible', '#type' => 'checkbox'); $form['exchange_rate_providers'][$plugin_id]['weight'] = array('#default_value' => $weight, '#title' => $this->t('Weight'), '#title_display' => 'invisible', '#type' => 'weight'); $operations_provider = $this->currencyExchangeRateProviderManager->getOperationsProvider($plugin_id); $form['exchange_rate_providers'][$plugin_id]['operations'] = array('#links' => $operations_provider ? $operations_provider->getOperations($plugin_id) : [], '#title' => $this->t('Operations'), '#type' => 'operations'); } $form['actions'] = array('#type' => 'actions'); $form['actions']['save'] = array('#button_type' => 'primary', '#type' => 'submit', '#value' => $this->t('Save')); return $form; }