Skip to content

Instantly share code, notes, and snippets.

@sheanhoxie
Last active July 24, 2020 21:32
Show Gist options
  • Select an option

  • Save sheanhoxie/eba865a0068f6637458295af9d56a833 to your computer and use it in GitHub Desktop.

Select an option

Save sheanhoxie/eba865a0068f6637458295af9d56a833 to your computer and use it in GitHub Desktop.
Problem:
--------
Trying to get a test to use a custom handler, defaultConfiguration()
in QuizFormHandler references a configuration setting called 'training_program'.
In order for this to work properly during install, Drupal needs to know the schema
of any handlers that have configuration settings
Webform missing schema error
----------------------------
Drupal\Core\Config\Schema\SchemaIncompleteException :
Schema errors for webform.webform.test_quiz_section_1 with the following errors:
webform.webform.test_quiz_section_1:handlers.quiz_handler.settings.training_program missing schema
Solution:
---------
Create schema file which provides the configuration referenced in QuizFormHandler.php
1. Create file named quiz_form_handler.schema.yml in mymodule/config/schema
2. the top-level key needs to be webform.handler.quiz_form_handler (must match id provided in @WebformHandler annotation)
3. the rest of the file defines the configuration
quiz_form_handler.schema.yml:
-----------------------------
webform.handler.quiz_form_handler:
type: mapping
label: 'Quiz Handler'
mapping:
training_program:
label: 'Training Program'
type: integer
QuizFormHandler.php - annotation
--------------------------------
/**
* Webform Quiz handler.
*
* @WebformHandler(
* id = "quiz_form_handler", <-- this webform handler's id
* label = @Translation("Quiz Handler"),
* category = @Translation("Quiz"),
* description = @Translation("Validate Quiz submissions."),
* cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
* results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
* submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL,
* )
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment