为了使屏幕阅读器可以访问电源邮件错误消息,我必须更改 HTML。
原始 Powermail
<div class="form-group powermail_fieldwrap_name has-error">
<label for="powermail_field_name">Name<span class="mandatory">*</span></label>
<input required="required" data-parsley-required-message="Dieses Feld muss ausgefüllt werden!" data-parsley-trigger="change" class="form-control " id="powermail_field_name" type="text" name="tx_powermail_pi1[field][name]" value="" data-parsley-id="12">
<ul class="help-block filled" id="parsley-id-12"><li class="parsley-required">Dieses Feld muss ausgefüllt werden!</li></ul>
</div>
无障碍
<div class="form-group powermail_fieldwrap_name has-error">
<label for="powermail_field_name">Name<span class="mandatory">*</span></label>
<input required="required" data-parsley-required-message="Dieses Feld muss ausgefüllt werden!" data-parsley-trigger="change" class="form-control " id="powermail_field_name" type="text" name="tx_powermail_pi1[field][name]" value="" data-parsley-id="12" aria-describedby="parsley-id-12">
<ul class="help-block filled" id="parsley-id-12"><li class="parsley-required">Dieses Feld muss ausgefüllt werden!</li></ul>
</div>
简而言之:我必须添加aria-describedby="parsley-id-12"
到<input>
.
在我自己的 Ext:powermail/Resources/Private/Partials/Form/Field/Input.html 版本中,我将 additionalAttributes 更改为additionalAttributes="{aria-describedby:'error',vh:Validation.ValidationDataAttribute(field:field)}"
完成部分
{namespace vh=In2code\Powermail\ViewHelpers}
<div class="powermail_fieldwrap powermail_fieldwrap_type_input powermail_fieldwrap_{field.marker} {field.css} {settings.styles.framework.fieldAndLabelWrappingClasses}">
<label for="powermail_field_{field.marker}" class="{settings.styles.framework.labelClasses}" title="{field.description}">
<vh:string.RawAndRemoveXss>{field.title}</vh:string.RawAndRemoveXss><f:if condition="{field.mandatory}"><span class="mandatory">*</span></f:if>
</label>
<div class="{settings.styles.framework.fieldWrappingClasses}">
<f:form.textfield
type="{vh:Validation.FieldTypeFromValidation(field:field)}"
property="{field.marker}"
placeholder="{field.placeholder}"
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="{aria-describedby:'error',vh:Validation.ValidationDataAttribute(field:field)}"
id="powermail_field_{field.marker}" />
</div>
</div>
这结束于
参数“additionalAttributes”注册为“array”类型,但在视图助手“TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper”中属于“string”类型