Skip to content

Commit

Permalink
Merge c16c7f2 into 2c4b5f4
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Oct 9, 2021
2 parents 2c4b5f4 + c16c7f2 commit a301b61
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TaskType extends AbstractType
'allow_remove' => true,
'allow_move_up' => true,
'allow_move_down' => true,
'render_expanded' => false,
'call_post_add_on_init' => true,
'prototype' => true,
])
// ...
Expand Down
2 changes: 0 additions & 2 deletions src/Form/CollectionJsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults([
'allow_move_up' => false,
'allow_move_down' => false,
'render_expanded' => false,
'entry_options' => function (OptionsResolver $entryOptionsResolver) {
$entryOptionsResolver
->setDefaults([
Expand All @@ -55,7 +54,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$view->vars = array_replace($view->vars, [
'allow_move_up' => $options['allow_move_up'],
'allow_move_down' => $options['allow_move_down'],
'render_expanded' => $options['render_expanded'],
'prototype_name' => $options['prototype_name'],
'call_post_add_on_init' => $options['call_post_add_on_init'],
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/views/bootstrap_5_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% block collection_js_entry_widget %}
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button {{ form_parent(form).vars.render_expanded ? '' : 'collapsed' }}" type="button" data-bs-toggle="collapse" data-bs-target="#{{ id }}-contents">
<button class="accordion-button {{ form.vars.valid ? 'collapsed' }}" type="button" data-bs-toggle="collapse" data-bs-target="#{{ id }}-contents">
<i class="fas fw fa-chevron-right form-collection-item-collapse-marker"></i>
{% if ea is defined %}
{{ value|ea_as_string }}
Expand Down Expand Up @@ -73,7 +73,7 @@
{% endapply %}
</div>
</h2>
<div id="{{ id }}-contents" class="accordion-collapse collapse {{ form_parent(form).vars.render_expanded ? 'show' }}">
<div id="{{ id }}-contents" class="accordion-collapse collapse {{ not form.vars.valid ? 'show' }}">
<div class="accordion-body">
{{ form_widget(form) }}
</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/Form/CollectionJsTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testDefaultOptions()
$view = $form->createView();
$this->assertFalse($view->vars['allow_move_up']);
$this->assertFalse($view->vars['allow_move_down']);
$this->assertFalse($view->vars['render_expanded']);
$this->assertFalse($view->vars['call_post_add_on_init']);
}

public function testCustomOptions()
Expand All @@ -40,7 +40,7 @@ public function testCustomOptions()
'entry_type' => TextType::class,
'allow_move_up' => true,
'allow_move_down' => true,
'render_expanded' => true,
'call_post_add_on_init' => true,
])
;
$this->assertSame([
Expand All @@ -52,6 +52,6 @@ public function testCustomOptions()
$view = $form->createView();
$this->assertTrue($view->vars['allow_move_up']);
$this->assertTrue($view->vars['allow_move_down']);
$this->assertTrue($view->vars['render_expanded']);
$this->assertTrue($view->vars['call_post_add_on_init']);
}
}

0 comments on commit a301b61

Please sign in to comment.