Add aria-describedBy on input
This commit is contained in:
parent
1f3a15e33b
commit
bf4d08c5ae
@ -309,7 +309,7 @@
|
||||
<div>
|
||||
{{- form_label(form) -}}
|
||||
{{- form_errors(form) -}}
|
||||
{{- form_widget(form) -}}
|
||||
{{- form_widget(form, { 'helpBlockDisplayed': true }) -}}
|
||||
{{- form_help(form) -}}
|
||||
</div>
|
||||
{%- endblock form_row -%}
|
||||
@ -397,6 +397,7 @@
|
||||
id="{{ id }}" name="{{ full_name }}"
|
||||
{%- if disabled %} disabled="disabled"{% endif -%}
|
||||
{%- if required %} required="required"{% endif -%}
|
||||
{%- if helpBlockDisplayed is defined and helpBlockDisplayed and help is not empty %} aria-describedby="{{ id }}HelpBlock"{% endif -%}
|
||||
{{ block('attributes') }}
|
||||
{%- endblock widget_attributes -%}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div>
|
||||
<?php echo $view['form']->label($form) ?>
|
||||
<?php echo $view['form']->errors($form) ?>
|
||||
<?php echo $view['form']->widget($form) ?>
|
||||
<?php echo $view['form']->help($form); ?>
|
||||
<?php echo $view['form']->widget($form, array('helpBlockDisplayed' => true)) ?>
|
||||
<?php echo $view['form']->help($form) ?>
|
||||
</div>
|
||||
|
@ -1,3 +1,4 @@
|
||||
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"<?php if ($disabled): ?> disabled="disabled"<?php endif ?>
|
||||
<?php if ($required): ?> required="required"<?php endif ?>
|
||||
<?php echo $attr ? ' '.$view['form']->block($form, 'attributes') : '' ?>
|
||||
<?php if (isset($helpBlockDisplayed) && $helpBlockDisplayed && !empty($help)): ?> aria-describedby="<?php echo $view->escape($id) ?>HelpBlock"<?php endif ?>
|
||||
<?php echo $attr ? ' '.$view['form']->block($form, 'attributes') : '' ?>
|
@ -436,6 +436,62 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
$this->assertMatchesXpath($html, '');
|
||||
}
|
||||
|
||||
public function testHelpSetLinkFromWidget()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
'help' => 'Help text test!',
|
||||
));
|
||||
$view = $form->createView();
|
||||
$html = $this->renderWidget($view, array('helpBlockDisplayed' => true));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[@aria-describedby="nameHelpBlock"]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpSetNotLinkedFromWidget()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array(
|
||||
'help' => 'Help text test!',
|
||||
));
|
||||
$view = $form->createView();
|
||||
$html = $this->renderWidget($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[not(@aria-describedby)]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpNotSetLinkFromWidget()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$view = $form->createView();
|
||||
$html = $this->renderWidget($view, array('helpBlockDisplayed' => true));
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[not(@aria-describedby)]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testHelpNotSetNotLinkedFromWidget()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
$view = $form->createView();
|
||||
$html = $this->renderWidget($view);
|
||||
|
||||
$this->assertMatchesXpath($html,
|
||||
'/input
|
||||
[not(@aria-describedby)]
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
public function testErrors()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
|
||||
|
Reference in New Issue
Block a user