Uploaded image for project: 'Magnolia Public User Registration'
  1. Magnolia Public User Registration
  2. MGNLPUR-205

Additional fields on the PUR form not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an issue
    • Neutral
    • None
    • 2.7.3
    • None
    • None

    Description

      Following the guide we provide at our docs to extend the userProfile we face an issue when sending the form to the processor: the parameters the createOrUpdateProfile method receives are empty, so no user is created in the end.

      Steps to reproduce

      Within a Magnolia module, create a CustomUserProfile which extends UserProfile with the following code

      CustomUserProfile.java
       private String phoneNumber = "";
      	
          public String getPhoneNumber() {
              return phoneNumber;
          }
          public void setPhoneNumber(String phoneNumber) {
              this.phoneNumber = phoneNumber;
          }

      Include the jar at the Magnolia Public instance of your project. Startup Magnolia and set your class at /modules/public-user-registration/config/configurations/default/userProfileConfiguration@userProfileClass

      Now include an attribute at /modules/public-user-registration/config/configurations/default/userProfileConfiguration/autopopulatedProperties named phoneNumber

      Next step is define the customRegistrationForm as follows:

      my-module/customRegistration.yaml
      title: User registration
      templateScript: /my-module/templates/components/customRegistration.ftl
      dialog: form:form
      modelClass: info.magnolia.module.publicuserregistration.form.UserFormModel
      class: info.magnolia.module.form.templates.components.FormParagraph
      renderType: freemarker
      formProcessors:
        registration:
          class: info.magnolia.module.publicuserregistration.processors.RegistrationProcessor
          enabled: true
      

      And the FTL could be something like:

      my-module/customRegistration.ftl
      <form name="${content.formName?default('form1')}" method="post" action="" enctype="multipart/form-data">
          <div class="form-item-hidden">
              <input type="hidden" name="mgnlModelExecutionUUID" value="${content.@uuid}"/>
      		<input type="hidden" name="field" value="" />
              <input type="hidden" name="csrf" value="${ctx.getAttribute('csrf')!''}" />
          </div>
          <div class="form-section">
              <div class="form-item-hidden">
                  <label for="username">
                      <span>
                          Username
                          <dfn title="required">*</dfn>
                      </span>
                  </label>
                  <input name="username" id="username" required="" autofocus="" autocomplete="on" type="text" value="">
                  <br>
                  <label for="password">
                      <span>
                          Password
                          <dfn title="required">*</dfn>
                      </span>
                  </label>
                  <input name="password" id="password" required="" autocomplete="off" type="password" value="">
                  <br>
                  <label for="passwordConfirmation">
                      <span>
                          Password confirmation
                          <dfn title="required">*</dfn>
                      </span>
                  </label>
                  <input name="passwordConfirmation" id="passwordConfirmation" required="" autocomplete="off" type="password" value="">
                  <br>
                  <label for="fullName">
                      <span>
                          Full name
                          <dfn title="required">*</dfn>
                      </span>
                  </label>
                  <input name="fullName" id="fullName" required="" autocomplete="on" type="text" value="">
                  <br>
                  <label for="phoneNumber">
                      <span>
                          phone Number
                      </span>
                  </label>
                  <input name="phoneNumber" id="phoneNumber" autocomplete="on" type="text" value="">
                  <br>
                  <label for="email">
                      <span>
                          Email
                          <dfn title="required">*</dfn>
                      </span>
                  </label>
                  <input name="email" id="email" required="" autocomplete="on" type="email" value="">
                  <br>
                  <input type="submit" value="Register">
              </div>
          </div>
      </form>
      

      Now include your new component within an area at a page template as follows

      mtk/templates/pages/basic.yaml
      register:
        id: my-module:components/customRegistration
      

      Now access the page and send the form. If you debug the RegistrationProcessor class, you will see that at the createOrUpdateProfile method, the parameters received are null when they should have data.

      Attached some screenshots that may help.

      Checklists

        Acceptance criteria

        Attachments

          1. createOrUpdateProfile.png
            createOrUpdateProfile.png
            355 kB
          2. customRegistration.ftl
            2 kB
          3. customRegistration.yaml
            0.4 kB
          4. form-sending-data.png
            form-sending-data.png
            255 kB

          Activity

            People

              efochr Evzen Fochr
              ccantalapiedra Carlos Cantalapiedra
              AdminX
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD