You are here

interface InlineFormInterface in Commerce Core 8.2

Defines the interface for inline forms.

Inline forms are embeddable and reusable. They are used as an alternative to building complex custom form elements, which have problems with rebuilding on #ajax due to being processed too early. Unlike form elements, inline forms support dependency injection and allow swapping out the implementing class through an alter hook.

Just like form elements, inline forms are automatically validated and submitted when the complete form is validated/submitted.

Hierarchy

Expanded class hierarchy of InlineFormInterface

All classes that implement InlineFormInterface

1 file declares its use of InlineFormInterface
InlineFormManager.php in src/InlineFormManager.php

File

src/Plugin/Commerce/InlineForm/InlineFormInterface.php, line 21

Namespace

Drupal\commerce\Plugin\Commerce\InlineForm
View source
interface InlineFormInterface extends ConfigurableInterface, PluginInspectionInterface {

  /**
   * Gets the inline form label.
   *
   * @return string
   *   The inline form label.
   */
  public function getLabel();

  /**
   * Builds the inline form.
   *
   * @param array $inline_form
   *   The inline form, containing the following basic properties:
   *   - #parents: Identifies the location of the field values in $form_state.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state of the complete form.
   *
   * @return array
   *   The built inline form.
   */
  public function buildInlineForm(array $inline_form, FormStateInterface $form_state);

  /**
   * Validates the inline form.
   *
   * @param array $inline_form
   *   The inline form, containing the following basic properties:
   *   - #parents: Identifies the location of the field values in $form_state.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state of the complete form.
   */
  public function validateInlineForm(array &$inline_form, FormStateInterface $form_state);

  /**
   * Submits the inline form.
   *
   * @param array $inline_form
   *   The inline form, containing the following basic properties:
   *   - #parents: Identifies the location of the field values in $form_state.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state of the complete form.
   */
  public function submitInlineForm(array &$inline_form, FormStateInterface $form_state);

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 11
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 12
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 12
InlineFormInterface::buildInlineForm public function Builds the inline form. 1
InlineFormInterface::getLabel public function Gets the inline form label. 1
InlineFormInterface::submitInlineForm public function Submits the inline form. 1
InlineFormInterface::validateInlineForm public function Validates the inline form. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2