3 namespace Drupal\entity_browser;
4 use Drupal\Core\Form\FormStateInterface;
7 * Provides base form methods for configurable plugins entity browser.
9 trait PluginConfigurationFormTrait {
12 * Implements PluginFormInterface::buildConfigurationForm().
14 public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
19 * Implements PluginFormInterface::validateConfigurationForm().
21 public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
25 * Implements PluginFormInterface::submitConfigurationForm().
27 * This is the default implementation for the most common cases where the form
28 * element names match keys in configuration array. Plugins can override this
29 * if they need more complex logic.
31 public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
32 $values = $form_state->getValues();
34 if ($this instanceof WidgetInterface) {
35 $values = $values['table'][$this->uuid()]['form'];
38 if (!empty($values)) {
39 foreach ($values as $key => $value) {
40 if (array_key_exists($key, $this->configuration)) {
41 $this->configuration[$key] = $value;