in2code-de / femanager

Modern TYPO3 Frontend User RegistrationTYPO3 Frontend User Registration and Management based on Extbase and Fluid and on TYPO3 (version 8 or newer) and the possibility to extend it to your needs.
https://www.in2code.de/agentur/typo3-extensions/femanager/
48 stars 118 forks source link

Prefill of gender value in new settings will be ignored #486

Open mediaessenz opened 1 year ago

mediaessenz commented 1 year ago
plugin.tx_femanager.settings.new.prefill {
    gender = TEXT
    gender.value = 2
}

has no effect of the gender radio boxes in the register new user form.

Always the radio element with value 0 (male) will be checked, independent of the defined prefill value.

The user object, which is used to compare the value inside the corresponding gender partial is null.

mediaessenz commented 1 year ago

As a temporary workaround for an installation, where I use gender value 2 for a neutral salutation, which should be the default in this case, I changed the gender partial this way:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:femanager="http://typo3.org/ns/In2code/Femanager/ViewHelpers"
      data-namespace-typo3-fluid="true">

<div class="femanager_fieldset femanager_gender form-group">
    <label class="control-label">
        <f:translate key="tx_femanager_domain_model_user.gender" />
        <f:if condition="{femanager:Validation.IsRequiredField(fieldName:'gender')}">
            <span>*</span>
        </f:if>
    </label>
    <div class="form-check-inline">
        <div class="radio">
            <label>
                <f:form.radio
                    id="femanager_field_gender1"
                    property="gender"
                    value="1"
                    checked="{user.gender} == 1"
                    additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'gender')}" />
                <f:translate key="tx_femanager_domain_model_user.gender.item1" />
            </label>
        </div>
        <div class="radio">
            <label>
                <f:form.radio
                    id="femanager_field_gender0"
                    property="gender"
                    value="0"
                    checked="{user} && {user.gender} == 0"
                    additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'gender')}" />
                <f:translate key="tx_femanager_domain_model_user.gender.item0" />
            </label>
        </div>
        <div class="radio">
            <label>
                <f:form.radio
                    id="femanager_field_gender2"
                    property="gender"
                    value="2"
                    checked="!{user} || {user} == 2"
                    additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'gender')}" />
                <f:translate key="tx_femanager_domain_model_user.gender.item2" />
            </label>
        </div>
    </div>
</div>
</html>