Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Custom Option Field Validation not working, only if Client (JS) Validation enabled #1176

Open
hendrikreimers opened this issue Oct 24, 2024 · 2 comments

Comments

@hendrikreimers
Copy link

I added a custom Field with TSconfig as follows:

tx_powermail.flexForm.type.addFieldOptions {
    privacy = Datenschutzhinweis (DSGVO)
    privacy.dataType = 0
    privacy.export = 1
}

And created a partial template, based on checkbox as well:

{namespace vh=In2code\Powermail\ViewHelpers}
<f:variable name="privacyPageUrl">{f:uri.page(pageUid: settings.misc.privacyPage)}</f:variable>
<f:variable name="setting" value="{field.modifiedSettings.0}" />
<div class="powermail_fieldwrap powermail_fieldwrap_type_check powermail_fieldwrap_{field.marker} {field.css} {settings.styles.framework.fieldAndLabelWrappingClasses}">
    <p class="field-wrap-label">
        <vh:string.escapeLabels>{field.title}</vh:string.escapeLabels><f:if condition="{field.mandatory}"><span class="mandatory"> *</span></f:if>
    </p>

    <div class="{settings.styles.framework.fieldWrappingClasses}">
        <div class="{settings.styles.framework.checkClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}">
            <div class="checkbox-item">
                <label class="checkbox-item__label" for="powermail_field_{field.marker}"><f:format.html parseFuncTSPath=""><f:translate key="LLL:EXT:my_site_ext/Resources/Private/Language/locallang.xlf:powermail.field.privacy.label" arguments="{0: privacyPageUrl}" /></f:format.html>
                    <f:form.checkbox
                        property="{field.marker}"
                        value="1"
                        id="powermail_field_{field.marker}"
                        additionalAttributes="{vh:Validation.ValidationDataAttribute(field:field,)}"
                        class="powermail_checkbox powermail_checkbox_{field.uid} checkbox-item__input {vh:validation.errorClass(field:field, class:'powermail_field_error')}" />
                    <span class="checkbox-item__fake-input"></span>
                    <span class="checkbox-item__focus-indicator"></span>
                </label>
            </div>
        </div>

        <f:if condition="{settings.validation.client}">
            <div class="powermail_field_error_container powermail_field_error_container_{field.marker}"></div>
        </f:if>
    </div>
</div>

In the Form dataset the field is set to "Mandatory".

But if you submit the form in the frontend, the validation not checks the new field. The required string "*" (star) is visible, but it's not validated. But if i'm enabling the client validation (JS Validation) it works:
TS Setup: plugin.tx_powermail.settings.setup.validation.client = 1

I tried multiple options in the form (like different validations), tried TSconfig different dataType's, as well as different kind of form field configuration in Partial Fluid Template (as array for example like original checkbox partial etc).

It only works if i'm enabling the client side validation.

Please fix it.

Thanks a lot.

@hendrikreimers hendrikreimers changed the title [BUG] Custom Field Validation not working, only if Client (JS) Validation enabled [BUG] Custom Option Field Validation not working, only if Client (JS) Validation enabled Oct 24, 2024
@mschwemer
Copy link
Collaborator

I would really appreciate, if you could provide a bugfix and PR for it.

Best regards
Marcus

@hendrikreimers
Copy link
Author

I don't know how to fix it, because i don't know how the validation works in Powermail.
If you give me some hints, i could try it.

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

No branches or pull requests

2 participants