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

[FEATURE] Unique field ids #665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
class PasswordValidationDataAttributeViewHelper extends ValidationDataAttributeViewHelper
{

/**
* @return void
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('ttContentUid', 'int', 'UID of content element', false);
}

/**
* Returns Data Attribute Array for JS validation with parsley.js
*
Expand All @@ -25,7 +34,11 @@ public function render(): array
if ($this->isClientValidationEnabled()) {
/** @var Field $field */
$field = $this->arguments['field'];
$ttContentUid = $this->arguments['ttContentUid'];
$additionalAttributes['data-parsley-equalto'] = '#powermail_field_' . $field->getMarker();
if ($ttContentUid) {
$additionalAttributes['data-parsley-equalto'] = $additionalAttributes['data-parsley-equalto'] . '_' . $ttContentUid;
}
$additionalAttributes['data-parsley-equalto-message'] =
LocalizationUtility::translate('validationerror_password');
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Captcha.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="{settings.styles.framework.fieldWrappingClasses} {vh:validation.errorClass(field:field, class: 'powermail_field_error')}">
<f:form.textfield
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
value=""
class="powermail_captcha {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}"
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Check.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
property="{field.marker}."
value="{setting.value}"
checked="{vh:misc.prefillMultiField(field:field, mail:mail, cycle:index.cycle)}"
id="powermail_field_{field.marker}_{index.cycle}"
id="powermail_field_{field.marker}_{ttContentUid}_{index.cycle}"
additionalAttributes="{vh:validation.validationDataAttribute(field:field, iteration:index)}"
class="powermail_checkbox powermail_checkbox_{field.uid}" />
<vh:string.escapeLabels>{setting.label}</vh:string.escapeLabels>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Country.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
class="powermail_country {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}"
value="{vh:misc.prefillField(field:field, mail:mail)}"
additionalAttributes="{vh:validation.validationDataAttribute(field:field)}"
id="powermail_field_{field.marker}" />
id="powermail_field_{field.marker}_{ttContentUid}" />
</div>
</div>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Date.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="{settings.styles.framework.fieldWrappingClasses}">
<f:form.textfield
type="{field.datepickerSettingsOptimized}"
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
value="{vh:misc.prefillField(field:field, mail:mail)}"
additionalAttributes="{vh:validation.datepickerDataAttribute(field:field, value:'{vh:misc.prefillField(field:field)}')}"
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/File.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="{settings.styles.framework.fieldWrappingClasses}">
<vh:form.multiUpload
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
additionalAttributes="{vh:validation.uploadAttributes(field:field)}"
class="powermail_file {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class: 'powermail_field_error')}" />
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Hidden.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{namespace vh=In2code\Powermail\ViewHelpers}
<f:form.hidden
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
value="{vh:misc.prefillField(field:field, mail:mail)}"
class="powermail_hidden {field.css} powermail_{field.marker}" />
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Input.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
value="{vh:misc.prefillField(field:field, mail:mail)}"
class="powermail_input {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}"
additionalAttributes="{vh:validation.validationDataAttribute(field:field)}"
id="powermail_field_{field.marker}" />
id="powermail_field_{field.marker}_{ttContentUid}" />
</div>
</div>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Location.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="{settings.styles.framework.fieldWrappingClasses}">
<f:form.textfield
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
value="{vh:misc.prefillField(field:field, mail:mail)}"
additionalAttributes="{data-powermail-location:'prefill'}"
Expand Down
8 changes: 4 additions & 4 deletions Resources/Private/Partials/Form/Field/Password.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="{settings.styles.framework.fieldWrappingClasses}">
<f:form.password
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
value=""
additionalAttributes="{vh:validation.validationDataAttribute(field:field)}"
Expand All @@ -15,17 +15,17 @@

<div class="powermail_fieldwrap powermail_fieldwrap_type_password powermail_fieldwrap_{field.marker} powermail_fieldwrap_{field.marker}_mirror {field.css} {settings.styles.framework.fieldAndLabelWrappingClasses}">
<f:if condition="{field.css} != 'nolabel'">
<label for="powermail_field_{field.marker}_mirror" class="{settings.styles.framework.labelClasses}">
<label for="powermail_field_{field.marker}_{ttContentUid}_mirror" class="{settings.styles.framework.labelClasses}">
<f:translate key="writePasswordAgain" /><f:if condition="{field.mandatory}"><span class="mandatory">*</span></f:if>
</label>
</f:if>

<div class="{settings.styles.framework.fieldWrappingClasses}">
<f:form.password
id="powermail_field_{field.marker}_mirror"
id="powermail_field_{field.marker}_{ttContentUid}_mirror"
property="{field.marker}_mirror"
value=""
additionalAttributes="{vh:validation.passwordValidationDataAttribute(field:field)}"
additionalAttributes="{vh:validation.passwordValidationDataAttribute(field:field, ttContentUid:ttContentUid)}"
class="powermail_password {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}" />
</div>
</div>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
property="{field.marker}"
value="{setting.value}"
checked="{vh:misc.prefillMultiField(field:field, mail:mail, cycle:index.cycle)}"
id="powermail_field_{field.marker}_{index.cycle}"
id="powermail_field_{field.marker}_{ttContentUid}_{index.cycle}"
additionalAttributes="{vh:validation.validationDataAttribute(field:field, iteration:index)}"
class="powermail_radio" />
<vh:string.escapeLabels>{setting.label}</vh:string.escapeLabels>
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Select.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
options="{field.modifiedSettings}"
property="{field.marker}"
class="powermail_select {settings.styles.framework.fieldClasses} {vh:validation.errorClass(field:field, class:'powermail_field_error')}"
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
additionalAttributes="{vh:validation.validationDataAttribute(field:field)}"
multiple="{field.multiselectForField}"
value="{vh:misc.prefillField(field:field, mail:mail)}" />
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Field/Textarea.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<f:form.textarea
cols="20"
rows="5"
id="powermail_field_{field.marker}"
id="powermail_field_{field.marker}_{ttContentUid}"
property="{field.marker}"
placeholder="{field.placeholder}"
value="{vh:misc.prefillField(field:field, mail:mail)}"
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/FieldLabel.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</f:comment>

<f:if condition="{field.css} != 'nolabel'">
<label for="powermail_field_{field.marker}" class="{settings.styles.framework.labelClasses}" title="{field.description}">
<label for="powermail_field_{field.marker}_{ttContentUid}" class="{settings.styles.framework.labelClasses}" title="{field.description}">
<vh:string.escapeLabels>{field.title}</vh:string.escapeLabels><f:if condition="{field.mandatory}"><span class="mandatory">*</span></f:if>
</label>
</f:if>
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Form/Page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<f:for each="{page.fields}" as="field" iteration="iteration">
<vh:misc.createRowTags columns="{settings.styles.numberOfColumns}" class="{settings.styles.framework.rowClasses}" iteration="{iteration}">
<f:render partial="Form/Field/{vh:String.Upper(string:field.type)}" arguments="{field:field}" />
<f:render partial="Form/Field/{vh:String.Upper(string:field.type)}" arguments="{field:field, ttContentUid:ttContentData.uid}" />
</vh:misc.createRowTags>
</f:for>
</fieldset>