PluginFormInterface.php 2.03 KB
Newer Older
1 2
<?php

3
namespace Drupal\Core\Plugin;
4

5 6
use Drupal\Core\Form\FormStateInterface;

7
/**
8
 * Provides an interface for an embeddable plugin form.
9
 *
10
 * @ingroup plugin_api
11
 */
12
interface PluginFormInterface {
13 14 15 16

  /**
   * Form constructor.
   *
17 18 19 20 21 22 23 24
   * Plugin forms are embedded in other forms. In order to know where the plugin
   * form is located in the parent form, #parents and #array_parents must be
   * known, but these are not available during the initial build phase. In order
   * to have these properties available when building the plugin form's
   * elements, let this method return a form element that has a #process
   * callback and build the rest of the form in the callback. By the time the
   * callback is executed, the element's #parents and #array_parents properties
   * will have been set by the form API. For more documentation on #parents and
25
   * #array_parents, see \Drupal\Core\Render\Element\FormElement.
26
   *
27
   * @param array $form
28
   *   An associative array containing the initial structure of the plugin form.
29
   * @param \Drupal\Core\Form\FormStateInterface $form_state
30
   *   The current state of the complete form.
31 32 33 34
   *
   * @return array
   *   The form structure.
   */
35
  public function buildConfigurationForm(array $form, FormStateInterface $form_state);
36 37 38 39 40

  /**
   * Form validation handler.
   *
   * @param array $form
41 42
   *   An associative array containing the structure of the plugin form as built
   *   by static::buildConfigurationForm().
43
   * @param \Drupal\Core\Form\FormStateInterface $form_state
44
   *   The current state of the complete form.
45
   */
46
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state);
47 48 49 50 51

  /**
   * Form submission handler.
   *
   * @param array $form
52 53
   *   An associative array containing the structure of the plugin form as built
   *   by static::buildConfigurationForm().
54
   * @param \Drupal\Core\Form\FormStateInterface $form_state
55
   *   The current state of the complete form.
56
   */
57
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state);
58 59

}