DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Adding fields to the registration form

Beginning with onetimeaccount version 0.5.0 you can add additional fields to the onetimeaccount registration form. The fields to be added have to exist in the fe_users table in your database.

Let’s say you want to add a simple input field for a mobile phone number. This is best done by creating a small extension which holds the necessary stuff for the new field.

The extension to be created should:

  1. add the field mobile_phone to the fe_users table,
  2. have a locallang.xlf file containing the labels and the validation messages for the field mobile_phone,
  3. add the FORMidable configuration for the field mobile_phone via TypoScript setup to plugin.tx_onetimeaccount_pi1.form.

The FORMidable configuration to be added via TypoScript setup in step 3 would look like this for our example:

plugin.tx_onetimeaccount_pi1.form.elements.mobile_phone = renderlet:TEXT
plugin.tx_onetimeaccount_pi1.form.elements.mobile_phone {
        name = mobile_phone
        process.userobj {
                extension = this
                method = isFormFieldEnabled
                params {
                        10.name = elementName
                        10.value = mobile_phone
                }
        }
        validators {
                10 = validator:STANDARD
                10.userobj {
                        message = LLL:EXT:yourextensionkey/locallang.xlf:message_mobile_phone
                        extension = this
                        method = validateStringField
                        params {
                                10.name = elementName
                                10.value = mobile_phone
                        }
                }
                20 = validator:PREG
                20.pattern {
                        value = /^([\d\+][\d \-\+\/]*[\d\+])?$/
                        message = LLL:EXT:yourextensionkey/locallang.xlf:message_malformed_mobile_phone
                }
        }
}

The following has to be done manually:

  1. add the field mobile_phone via TypoScript setup to plugin.tx_onetimeaccount_pi1.feUserFieldsToDisplay,

  2. add the field mobile_phone via TypoScript setup to plugin.tx_onetimeaccount_pi1.requiredFeUserFields if necessary,

  3. add a marker to the HTML template, e.g.:

    <!-- ###WRAPPER_MOBILE_PHONE### -->
     <dt>
     <label for="tx_onetimeaccount_pi1_form_mobile_phone"###MOBILE_HONE_REQUIRED###>
     ###LABEL_MOBILE_PHONE###
     </label>
     </dt>
     <dd>
     {mobile_phone}
     </dd>
    <!-- ###WRAPPER_MOBILE_PHONE### -->
    

Please notice that it is currently not possible to select non-default fields via FlexForms.

If you want to add other types of form fields (textareas, radio buttons, checkboxes, etc.) please have a look at the default TypoScript setup configuration of onetimeaccount in plugin.tx_onetimeaccount_pi1.form and/or the FORMidable manual.