class SubformState in Markdown 8.2
Same name in this branch
- 8.2 src/Form/SubformState.php \Drupal\markdown\Form\SubformState
- 8.2 src/BcSupport/SubformState.php \Drupal\markdown\BcSupport\SubformState
Markdown subform state.
Hierarchy
- class \Drupal\markdown\BcSupport\FormStateDecoratorBase implements FormStateInterface
- class \Drupal\markdown\BcSupport\SubformState implements SubformStateInterface uses FormStateValuesTrait
- class \Drupal\markdown\Form\SubformState implements SubformStateInterface uses FormTrait
- class \Drupal\markdown\BcSupport\SubformState implements SubformStateInterface uses FormStateValuesTrait
Expanded class hierarchy of SubformState
2 files declare their use of SubformState
- CommonMark.php in src/
Plugin/ Markdown/ CommonMark/ CommonMark.php - FilterMarkdown.php in src/
Plugin/ Filter/ FilterMarkdown.php
File
- src/
Form/ SubformState.php, line 13
Namespace
Drupal\markdown\FormView source
class SubformState extends CoreSubformState implements SubformStateInterface {
use FormTrait {
addElementState as traitAddElementState;
}
/**
* {@inheritdoc
*/
protected function __construct(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) {
$this->decoratedFormState = $parent_form_state;
$this->parentForm =& $parent_form;
$this->subform =& $subform;
}
/**
* {@inheritdoc
*/
public function conditionalElement(array $element, $state, $name, array $conditions) {
$element += [
'#type' => 'html_tag',
];
if ($element['#type'] === 'container') {
$element += [
'#theme_wrappers' => [
'container__markdown_conditional_element__' . $name,
],
];
}
if ($element['#type'] === 'html_tag') {
$element += [
'#tag' => 'span',
];
}
$element['#attributes']['class'][] = 'js-form-item';
$this
->addElementState($element, $state, $name, $conditions);
// Older versions of Drupal core do not have the necessary helper method:
// \Drupal\Core\Form\FormHelper::processStates. Instead of completely
// back-porting that entire class, we'll just do what it does here.
// @todo Replace with FormHelper::processStates() in D9.
$element['#attached']['library'][] = 'core/drupal.states';
$element['#attributes']['data-drupal-states'] = Json::encode($element['#states']);
return drupal_render($element);
}
/**
* {@inheritdoc}
*/
public static function createForSubform(array &$subform, array &$parent_form, FormStateInterface $parent_form_state) {
// Attempt to construct #parents array based on passed values.
if (!isset($subform['#parents']) && $parent_form_state instanceof SubformStateInterface && ($name = array_search($subform, $parent_form, TRUE))) {
$subform['#parents'] = array_merge($parent_form_state
->getAllParents(), [
$name,
]);
}
return parent::createForSubform($subform, $parent_form, $parent_form_state);
}
/**
* {@inheritdoc}
*/
public function addElementState(array &$element, $state, $name, array $conditions, array $parents = NULL) {
if (!isset($parents)) {
$parents = $this
->getAllParents();
}
static::traitAddElementState($element, $state, $name, $conditions, $parents);
}
/**
* {@inheritdoc}
*/
public function createParents($name = NULL, $property = '#parents') {
$parents = $this
->getAllParents($property);
if ($name) {
$parents = array_merge($parents, (array) $name);
}
return $parents;
}
/**
* {@inheritdoc}
*/
public function getAllParents($property = '#parents') {
if (!isset($this->parentForm[$property])) {
throw new \RuntimeException(sprintf('The subform and parent form must contain the %s property, which must be an array. Try calling this method from a #process callback instead.', $property));
}
// Merge the parent form and subform's relative parents.
return array_merge($this->parentForm[$property], $this
->getParents($property));
}
/**
* {@inheritdoc}
*/
public function &getParentForm() {
return $this->parentForm;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormStateDecoratorBase:: |
protected | property | The decorated form state. | |
FormStateDecoratorBase:: |
public | function |
Adds a value to the build info. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Adds a key to the array of form values that will be cleaned. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Adds a value to the rebuild info. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Removes internal Form API elements and buttons from submitted form values. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Clears all errors against all form elements made by self::setErrorByName(). Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Prevents the form from being cached. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Prevents the form from redirecting. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets any arbitrary property. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if this form should always be processed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the build info for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the submit and button elements for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns an array representation of the cacheable portion of the form state. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the keys of the form values that will be cleaned. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns a reference to the complete form array. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the error message filed against the given form element. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns an associative array of all errors. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the form object that is responsible for building this form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns references to details elements to render them within vertical tabs. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the rebuild info. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the value to use for redirecting after the form has been executed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets a response for this form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the entire set of arbitrary data. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the submit handlers. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets temporary data. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets an arbitrary value from temporary storage. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the form element that triggered submission. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the form values as they were submitted by the user. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Gets the validate handlers. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if an arbitrary property is present. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public static | function |
Determines if any forms have any errors. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns whether this form has a file element. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form has an invalid token. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if a temporary value is present. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if this form submission should bypass #access. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form should be cached. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form was submitted and has been processed and executed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns the HTTP form method. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form input will be processed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Returns if this form was submitted programmatically. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form should be rebuilt after processing. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if redirecting has been prevented. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if the form has been submitted. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Determines if validation has been completed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Checks if validation is enforced. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Ensures an include file is loaded whenever the form is processed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Converts support notations for a form callback to a valid callable. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets a value to an arbitrary property. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets this form to always be processed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the build info for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Stores the submit and button elements for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets this form to be cached. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the keys of the form values that will be cleaned. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Stores the complete form array. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Flags an element as having an error. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that the form was submitted and has been processed and executed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the form object that is responsible for building this form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the value of the form state. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets references to details elements to render them within vertical tabs. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that this form has a file element. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Flags the form state as having or not an invalid token. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the HTTP method to use for the form's submission. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that the form should process input. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that this form was submitted programmatically. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets if this form submission should bypass #access. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the form to be rebuilt after processing. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the rebuild info. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the redirect for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the redirect URL for the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the HTTP method used by the request that is building the form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets a response for this form. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the entire set of arbitrary data. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the submit handlers. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that the form has been submitted. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets temporary data. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets an arbitrary value in temporary storage. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the form element that triggered submission. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the form values as though they were submitted by a user. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets the validate handlers. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Sets that validation has been completed. Overrides FormStateInterface:: |
|
FormStateDecoratorBase:: |
public | function |
Enforces that validation is run. Overrides FormStateInterface:: |
|
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::getValue() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::hasValue() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::isValueEmpty() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::setValue() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::setValueForElement() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::setValues() | |
FormStateValuesTrait:: |
public | function | Implements \Drupal\Core\Form\FormStateInterface::unsetValue() | |
FormTrait:: |
protected static | property | Flag indicating whether the token module exists. | |
FormTrait:: |
public static | function | Adds a data attribute to an element. | |
FormTrait:: |
public static | function | Adds multiple data attributes to an element. | |
FormTrait:: |
public static | function | Adds a #states selector to an element. Aliased as: traitAddElementState | |
FormTrait:: |
public static | function | Creates an element, adding data attributes to it if necessary. | |
FormTrait:: |
public static | function | Creates an inline status message to be used in a render array. | |
FormTrait:: |
public static | function | Creates a Token browser element for use when dealing with tokens. | |
FormTrait:: |
public static | function | Retrieves the selector for an element. | |
FormTrait:: |
public static | function | Allows a form element to be reset to its default value. | |
SubformState:: |
protected | property | The parent form. | |
SubformState:: |
protected | property | The subform. | |
SubformState:: |
public | function |
Adds a #states selector to an element. Overrides SubformStateInterface:: |
|
SubformState:: |
public | function |
{@inheritdoc Overrides SubformStateInterface:: |
|
SubformState:: |
public static | function |
Creates a new instance for a subform. Overrides SubformState:: |
|
SubformState:: |
public | function |
Creates a new parents array for a given element. Overrides SubformStateInterface:: |
|
SubformState:: |
public | function |
Retrieves all parents for the form state up to this point. Overrides SubformStateInterface:: |
|
SubformState:: |
public | function |
Gets the complete form state. Overrides SubformStateInterface:: |
|
SubformState:: |
public | function |
Retrieves the limited validation error sections. Overrides FormStateDecoratorBase:: |
|
SubformState:: |
public | function |
Retrieves the parent form/element. Overrides SubformStateInterface:: |
|
SubformState:: |
protected | function | Gets the subform's parents relative to its parent form. | |
SubformState:: |
public | function |
Implements \Drupal\Core\Form\FormStateInterface::getValues() Overrides FormStateValuesTrait:: |
|
SubformState:: |
public | function |
Files an error against a form element. Overrides FormStateDecoratorBase:: |
|
SubformState:: |
public | function |
Sets the limited validation error sections. Overrides FormStateDecoratorBase:: |
|
SubformState:: |
protected | function |
{@inheritdoc Overrides SubformState:: |