3 namespace Drupal\Core\Plugin;
5 use Drupal\Core\Form\FormStateInterface;
8 * Provides an interface for an embeddable plugin form.
10 * Plugins can implement this form directly, or a standalone class can be used.
11 * Decoupled forms can implement \Drupal\Component\Plugin\PluginAwareInterface
12 * in order to gain access to the plugin.
16 interface PluginFormInterface {
21 * Plugin forms are embedded in other forms. In order to know where the plugin
22 * form is located in the parent form, #parents and #array_parents must be
23 * known, but these are not available during the initial build phase. In order
24 * to have these properties available when building the plugin form's
25 * elements, let this method return a form element that has a #process
26 * callback and build the rest of the form in the callback. By the time the
27 * callback is executed, the element's #parents and #array_parents properties
28 * will have been set by the form API. For more documentation on #parents and
29 * #array_parents, see \Drupal\Core\Render\Element\FormElement.
32 * An associative array containing the initial structure of the plugin form.
33 * @param \Drupal\Core\Form\FormStateInterface $form_state
34 * The current state of the form. Calling code should pass on a subform
35 * state created through
36 * \Drupal\Core\Form\SubformState::createForSubform().
41 public function buildConfigurationForm(array $form, FormStateInterface $form_state);
44 * Form validation handler.
47 * An associative array containing the structure of the plugin form as built
48 * by static::buildConfigurationForm().
49 * @param \Drupal\Core\Form\FormStateInterface $form_state
50 * The current state of the form. Calling code should pass on a subform
51 * state created through
52 * \Drupal\Core\Form\SubformState::createForSubform().
54 public function validateConfigurationForm(array &$form, FormStateInterface $form_state);
57 * Form submission handler.
60 * An associative array containing the structure of the plugin form as built
61 * by static::buildConfigurationForm().
62 * @param \Drupal\Core\Form\FormStateInterface $form_state
63 * The current state of the form. Calling code should pass on a subform
64 * state created through
65 * \Drupal\Core\Form\SubformState::createForSubform().
67 public function submitConfigurationForm(array &$form, FormStateInterface $form_state);