interface SubformStateInterface

Same name in other branches
  1. 9 core/lib/Drupal/Core/Form/SubformStateInterface.php \Drupal\Core\Form\SubformStateInterface
  2. 10 core/lib/Drupal/Core/Form/SubformStateInterface.php \Drupal\Core\Form\SubformStateInterface
  3. 11.x core/lib/Drupal/Core/Form/SubformStateInterface.php \Drupal\Core\Form\SubformStateInterface

Stores information about the state of a subform.

In the context of Drupal's Form API, a subform is a form definition array that will be nested into a "parent" form. For instance:

$subform = [
    'method' => [
        '#type' => 'select',
    ],
];
$form = [
    // …
'settings' => $subform,
];

All input fields nested under "settings" are then considered part of that "subform". The concept is used mostly when the subform is defined by a different class (potentially even in a different module) than the parent form. This is often the case for plugins: a plugin's buildConfigurationForm() would then be handed an instance of this interface as the second parameter.

The benefit of doing this is that the plugin can then just define the form – and use the form state – as if it would define a "proper" form, not nested in some other form structure. This means that it won't have to know the key(s) under which its form structure will be nested – for instance, when retrieving the form values during form validation or submission.

Contrary to "proper" forms, subforms don't translate to a <form> tag in the HTML response. Instead, they can only be discerned in the HTML code by the nesting of the input tags' names.

Hierarchy

Expanded class hierarchy of SubformStateInterface

All classes that implement SubformStateInterface

See also

\Drupal\Core\Plugin\PluginFormInterface::buildConfigurationForm()

4 files declare their use of SubformStateInterface
ConditionPluginBase.php in core/lib/Drupal/Core/Condition/ConditionPluginBase.php
EditorBase.php in core/modules/editor/src/Plugin/EditorBase.php
InlineBlock.php in core/modules/layout_builder/src/Plugin/Block/InlineBlock.php
SubformStateTest.php in core/tests/Drupal/Tests/Core/Form/SubformStateTest.php

File

core/lib/Drupal/Core/Form/SubformStateInterface.php, line 42

Namespace

Drupal\Core\Form
View source
interface SubformStateInterface extends FormStateInterface {
    
    /**
     * Gets the complete form state.
     *
     * @return \Drupal\Core\Form\FormStateInterface
     */
    public function getCompleteFormState();

}

Members

Title Sort descending Modifiers Object type Summary Overrides
FormStateInterface::addBuildInfo public function Adds a value to the build info. 2
FormStateInterface::addCleanValueKey public function Adds a key to the array of form values that will be cleaned. 2
FormStateInterface::addRebuildInfo public function Adds a value to the rebuild info. 2
FormStateInterface::cleanValues public function Removes internal Form API elements and buttons from submitted form values. 2
FormStateInterface::clearErrors public function Clears all errors against all form elements made by self::setErrorByName(). 2
FormStateInterface::disableCache public function Prevents the form from being cached. 2
FormStateInterface::disableRedirect public function Prevents the form from redirecting. 2
FormStateInterface::get public function Gets any arbitrary property. 2
FormStateInterface::getAlwaysProcess public function Determines if this form should always be processed. 2
FormStateInterface::getBuildInfo public function Returns the build info for the form. 2
FormStateInterface::getButtons public function Returns the submit and button elements for the form. 2
FormStateInterface::getCacheableArray public function Returns an array representation of the cacheable portion of the form state. 2
FormStateInterface::getCleanValueKeys public function Gets the keys of the form values that will be cleaned. 2
FormStateInterface::getCompleteForm public function Returns a reference to the complete form array. 2
FormStateInterface::getError public function Returns the error message filed against the given form element. 2
FormStateInterface::getErrors public function Returns an associative array of all errors. 2
FormStateInterface::getFormObject public function Returns the form object that is responsible for building this form. 2
FormStateInterface::getGroups public function Returns references to details elements to render them within vertical tabs. 2
FormStateInterface::getLimitValidationErrors public function Retrieves the limited validation error sections. 2
FormStateInterface::getRebuildInfo public function Gets the rebuild info. 2
FormStateInterface::getRedirect public function Gets the value to use for redirecting after the form has been executed. 2
FormStateInterface::getResponse public function Gets a response for this form. 2
FormStateInterface::getStorage public function Returns the entire set of arbitrary data. 2
FormStateInterface::getSubmitHandlers public function Gets the submit handlers. 2
FormStateInterface::getTemporary public function Gets temporary data. 2
FormStateInterface::getTemporaryValue public function Gets an arbitrary value from temporary storage. 2
FormStateInterface::getTriggeringElement public function Gets the form element that triggered submission. 2
FormStateInterface::getUserInput public function Returns the form values as they were submitted by the user. 2
FormStateInterface::getValidateHandlers public function Gets the validate handlers. 2
FormStateInterface::getValue public function Returns the submitted form value for a specific key. 1
FormStateInterface::getValues public function Returns the submitted and sanitized form values. 1
FormStateInterface::has public function Determines if an arbitrary property is present. 2
FormStateInterface::hasAnyErrors public static function Determines if any forms have any errors. 2
FormStateInterface::hasFileElement public function Returns whether this form has a file element. 2
FormStateInterface::hasInvalidToken public function Determines if the form has an invalid token. 2
FormStateInterface::hasTemporaryValue public function Determines if a temporary value is present. 2
FormStateInterface::hasValue public function Determines if a specific key is present in the submitted form values. 1
FormStateInterface::isBypassingProgrammedAccessChecks public function Determines if this form submission should bypass #access. 2
FormStateInterface::isCached public function Determines if the form should be cached. 2
FormStateInterface::isExecuted public function Determines if the form was submitted and has been processed and executed. 2
FormStateInterface::isMethodType public function Returns the HTTP form method. 2
FormStateInterface::isProcessingInput public function Determines if the form input will be processed. 2
FormStateInterface::isProgrammed public function Returns if this form was submitted programmatically. 2
FormStateInterface::isRebuilding public function Determines if the form should be rebuilt after processing. 2
FormStateInterface::isRedirectDisabled public function Determines if redirecting has been prevented. 2
FormStateInterface::isSubmitted public function Determines if the form has been submitted. 2
FormStateInterface::isValidationComplete public function Determines if validation has been completed. 2
FormStateInterface::isValidationEnforced public function Checks if validation is enforced. 2
FormStateInterface::isValueEmpty public function Determines if a specific key has a value in the submitted form values. 1
FormStateInterface::loadInclude public function Ensures an include file is loaded whenever the form is processed. 2
FormStateInterface::prepareCallback public function Converts support notations for a form callback to a valid callable. 2
FormStateInterface::set public function Sets a value to an arbitrary property. 2
FormStateInterface::setAlwaysProcess public function Sets this form to always be processed. 2
FormStateInterface::setBuildInfo public function Sets the build info for the form. 2
FormStateInterface::setButtons public function Stores the submit and button elements for the form. 2
FormStateInterface::setCached public function Sets this form to be cached. 2
FormStateInterface::setCleanValueKeys public function Sets the keys of the form values that will be cleaned. 2
FormStateInterface::setCompleteForm public function Stores the complete form array. 2
FormStateInterface::setError public function Flags an element as having an error. 2
FormStateInterface::setErrorByName public function Files an error against a form element. 2
FormStateInterface::setExecuted public function Sets that the form was submitted and has been processed and executed. 2
FormStateInterface::setFormObject public function Sets the form object that is responsible for building this form. 2
FormStateInterface::setFormState public function Sets the value of the form state. 2
FormStateInterface::setGroups public function Sets references to details elements to render them within vertical tabs. 2
FormStateInterface::setHasFileElement public function Sets that this form has a file element. 2
FormStateInterface::setInvalidToken public function Flags the form state as having or not an invalid token. 2
FormStateInterface::setLimitValidationErrors public function Sets the limited validation error sections. 2
FormStateInterface::setMethod public function Sets the HTTP method to use for the form&#039;s submission. 2
FormStateInterface::setProcessInput public function Sets that the form should process input. 2
FormStateInterface::setProgrammed public function Sets that this form was submitted programmatically. 2
FormStateInterface::setProgrammedBypassAccessCheck public function Sets if this form submission should bypass #access. 2
FormStateInterface::setRebuild public function Sets the form to be rebuilt after processing. 2
FormStateInterface::setRebuildInfo public function Sets the rebuild info. 2
FormStateInterface::setRedirect public function Sets the redirect for the form. 2
FormStateInterface::setRedirectUrl public function Sets the redirect URL for the form. 2
FormStateInterface::setRequestMethod public function Sets the HTTP method used by the request that is building the form. 2
FormStateInterface::setResponse public function Sets a response for this form. 2
FormStateInterface::setStorage public function Sets the entire set of arbitrary data. 2
FormStateInterface::setSubmitHandlers public function Sets the submit handlers. 2
FormStateInterface::setSubmitted public function Sets that the form has been submitted. 2
FormStateInterface::setTemporary public function Sets temporary data. 2
FormStateInterface::setTemporaryValue public function Sets an arbitrary value in temporary storage. 2
FormStateInterface::setTriggeringElement public function Sets the form element that triggered submission. 2
FormStateInterface::setUserInput public function Sets the form values as though they were submitted by a user. 2
FormStateInterface::setValidateHandlers public function Sets the validate handlers. 2
FormStateInterface::setValidationComplete public function Sets that validation has been completed. 2
FormStateInterface::setValidationEnforced public function Enforces that validation is run. 2
FormStateInterface::setValue public function Sets the submitted form value for a specific key. 1
FormStateInterface::setValueForElement public function Changes submitted form values during form validation. 1
FormStateInterface::setValues public function Sets the submitted form values. 1
FormStateInterface::unsetValue public function Removes a specific key from the submitted form values. 1
SubformStateInterface::getCompleteFormState public function Gets the complete form state. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.