Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.
This repository was 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

Description

@JPustkuchen

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! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions