Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

Add option to display registrant form open by default if only one exists (show_entity_create_form) #158

Open
JPustkuchen opened this issue Feb 8, 2018 · 1 comment

Comments

@JPustkuchen
Copy link

Context: When displaying an event registration form (in our case using rng_quick and rng_contact) the default form display with the many options is much too complicated and it would be good and enough to display the registrant form with its field directly / initially.

I tried to solve this using a custom module and found out that "show_entity_create_form" controls that. See:

<?php
  /**
   * Get form state for opening the create-an-entity sub-form.
   *
   * @return boolean
   *   Wther the create-an-entity sub-form is open.
   */
  public function getShowCreateEntitySubform() {
    return (bool) $this->formState->get(array_merge($this->element['#parents'], ['show_entity_create_form']));
  }

  /**
   * Set form state for opening the create-an-entity sub-form.
   *
   * @param $value
   */
  public function setShowCreateEntitySubform($value) {
    $this->formState->set(array_merge($this->element['#parents'], ['show_entity_create_form']), $value);
  }
?>

(http://cgit.drupalcode.org/rng/tree/src/RegistrantsElementUtility.php?h=8.x-1.x)

$entity_create_form = $utility->getShowCreateEntitySubform(); checks for that in src/Element/Registrants.php but the function always returns FALSE in the current implementation if the toggle button is not clicked.

It would be very helpful to have an option or open the form by default if the arity is single and there is only one type of registration allowed. This makes a lot of sense I think and would be cool for UX! :)

@JPustkuchen
Copy link
Author

Drupal style patch attached to use with composer-patches for example.

rng-158-open_registrant_form_by_default_if_one_registrant_type.patch.txt

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant