Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute
This commit is contained in:
parent
d4a78fec32
commit
861d3075b3
@ -67,7 +67,7 @@
|
||||
|
||||
{% block choice_widget_collapsed %}
|
||||
{% spaceless %}
|
||||
{% if required and empty_value is none and not empty_value_in_choices %}
|
||||
{% if required and empty_value is none and not empty_value_in_choices and not multiple %}
|
||||
{% set required = false %}
|
||||
{% endif %}
|
||||
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<select
|
||||
<?php if ($required && $empty_value === null && $empty_value_in_choices === false && $multiple === false):
|
||||
$required = false;
|
||||
endif; ?>
|
||||
<?php echo $view['form']->block($form, 'widget_attributes', array(
|
||||
'required' => $required && (null !== $empty_value || $empty_value_in_choices)
|
||||
'required' => $required
|
||||
)) ?>
|
||||
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
|
||||
>
|
||||
|
@ -635,6 +635,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'choice', array('&a'), array(
|
||||
'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'),
|
||||
'required' => true,
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
));
|
||||
@ -642,6 +643,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/select
|
||||
[@name="name[]"]
|
||||
[@required="required"]
|
||||
[@multiple="multiple"]
|
||||
[
|
||||
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
||||
|
Reference in New Issue
Block a user