Skip to content
Snippets Groups Projects

Draft: Issue #3508641 by pdureau, grimreaper: Define form elements from SDC

Draft: Issue #3508641 by pdureau, grimreaper: Define form elements from SDC
3 open threads

Closes #3508641

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 21 */
    22 protected static $modules = [
    23 'system',
    24 'sdc_test',
    25 ];
    26
    27 /**
    28 * {@inheritdoc}
    29 */
    30 protected static $themes = ['sdc_theme_test'];
    31
    32 /**
    33 * {@inheritdoc}
    34 */
    35 public function getFormId(): string {
    36 return 'component_in_form_test';
  • Théodore Biadala
    Théodore Biadala @nod_ started a thread on an outdated change in commit ec9fa230
  • 1 {% set id = id|default('test-sdc-text-field-' ~ random()) %}
    2
    3 {% set input_attributes = create_attribute({
    4 type: 'text',
    5 name: form_state.value.name,
    6 id: id,
    7 value: form_state.value.value,
    8 }) %}
    9
    10 {% if form_state.value.required is not empty %}
    11 {% set input_attributes = input_attributes.setAttribute('required', true) %}
    12 {% endif %}
    13
    14 <div{{ attributes }}>
    15 <label class="form-label" for="{{ id }}">
  • Théodore Biadala left review comments

    left review comments

  • Shibin Das added 3 commits

    added 3 commits

    • 2436bdb3 - Simplify the empty check as expected value for "required" should be a boolean
    • d5d00ff9 - Use attributes object to print ID
    • 5980b9eb - Update form id to reflect we are testing sdc component as form element

    Compare with previous version

  • Thanks for instant feedback, I have updated the MR.

  • Shibin Das added 1 commit

    added 1 commit

    • 189ae98f - Add a test for element_validate for sdc form element

    Compare with previous version

  • Shibin Das added 1 commit

    added 1 commit

    Compare with previous version

  • Shibin Das added 1 commit

    added 1 commit

    • 36817061 - Add return type for custom validator

    Compare with previous version

  • Shibin Das added 2 commits

    added 2 commits

    • 9553b7b9 - Add some test to cover ajax behaviour
    • 0206a5eb - Add ajax pre-preprocess to Component element

    Compare with previous version

  • 161 176 '#slots' => [],
    162 177 '#propsAlter' => [],
    163 178 '#slotsAlter' => [],
    179 '#process' => [
    180 [static::class, 'processAjaxForm'],
    • I was adding tests for ajax support for component. I realized that adding #ajax was not enough. The Element class needs to subscribe to the corresponding processor as well. In order to support processing of #ajax, we would have to explicitly inject a processor [static::class, 'processAjaxForm'] like this. This opens up the question about what should be default set (if any) be there on ComponentElement? Should it behave more like FormElement where it doesn't have any processors, or should it be opinionated and implement some?

    • I wouldn't add support for the ajax stuff in sdc. SDC are largely drupal agnostic, we should keep it that way, meaning all the #ajax stuff should not be in there.

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading