function RecipeInputFormTrait::setRecipeInput

Supplies user-inputted values to a recipe and its dependencies.

Parameters

\Drupal\Core\Recipe\Recipe $recipe: A recipe.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state. The values should be organized in the tree structure that was returned by ::buildRecipeInputForm().

2 calls to RecipeInputFormTrait::setRecipeInput()
FormTestRecipeInputForm::submitForm in core/modules/system/tests/modules/form_test/src/Form/FormTestRecipeInputForm.php
Form submission handler.
RecipeInputFormTrait::validateRecipeInput in core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php
Validates user-inputted values to a recipe and its dependencies.

File

core/lib/Drupal/Core/Recipe/RecipeInputFormTrait.php, line 138

Class

RecipeInputFormTrait
Defines helper methods for forms which collect input on behalf of recipes.

Namespace

Drupal\Core\Recipe

Code

protected function setRecipeInput(Recipe $recipe, FormStateInterface $form_state) : void {
    $recipe->input
        ->collectAll(new class ($form_state) implements InputCollectorInterface {
        public function __construct(FormStateInterface $formState) {
        }
        
        /**
         * {@inheritdoc}
         */
        public function collectValue(string $name, DataDefinitionInterface $definition, mixed $default_value) : mixed {
            return $this->formState
                ->getValue(explode('.', $name, 2), $default_value);
        }

});
}

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