diff --git a/src/Bundle/ChillEventBundle/Controller/EventController.php b/src/Bundle/ChillEventBundle/Controller/EventController.php
index 9d4352a02..367c6c334 100644
--- a/src/Bundle/ChillEventBundle/Controller/EventController.php
+++ b/src/Bundle/ChillEventBundle/Controller/EventController.php
@@ -411,20 +411,17 @@ final class EventController extends AbstractController
]
);
- $builder->add('person_id', PickPersonDynamicType::class, ['as_id' => true, 'multiple' => false]);
+ $builder->add('person_id', PickPersonDynamicType::class, [
+ 'as_id' => true,
+ 'multiple' => false,
+ 'submit_on_adding_new_entity' => true,
+ 'label' => 'Add a participation',
+ ]);
$builder->add('event_id', HiddenType::class, [
'data' => $event->getId(),
]);
- $builder->add(
- 'submit',
- SubmitType::class,
- [
- 'label' => 'Add a participation',
- ]
- );
-
return $builder->getForm();
}
diff --git a/src/Bundle/ChillEventBundle/Controller/EventListController.php b/src/Bundle/ChillEventBundle/Controller/EventListController.php
index ffdc9c804..60df81240 100644
--- a/src/Bundle/ChillEventBundle/Controller/EventListController.php
+++ b/src/Bundle/ChillEventBundle/Controller/EventListController.php
@@ -101,7 +101,12 @@ final readonly class EventListController
]
);
- $builder->add('person_id', PickPersonDynamicType::class, ['as_id' => true, 'multiple' => false]);
+ $builder->add('person_id', PickPersonDynamicType::class, [
+ 'as_id' => true,
+ 'multiple' => false,
+ 'submit_on_adding_new_entity' => true,
+ 'label' => 'Add a participation',
+ ]);
$builder->add('event_id', HiddenType::class, [
'data' => $event->getId(),
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig
index 24b7c08a8..f22b56c05 100644
--- a/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig
+++ b/src/Bundle/ChillEventBundle/Resources/views/Event/page_list.html.twig
@@ -60,18 +60,13 @@
{% endif %}
{% endif %}
- {#
{{ form_start(eventForms[e.id]) }}
{{ form_widget(eventForms[e.id].person_id) }}
-
{{ form_end(eventForms[e.id]) }}
- #}
diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig
index b7e3b7d10..3156c61d8 100644
--- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig
+++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig
@@ -136,11 +136,8 @@
'class' : 'custom-select',
'style': 'min-width: 15em; max-width: 18em; display: inline-block;'
}} ) }}
-
- {{ form_widget(form_add_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-create' } } ) }}
-
- {{ form_rest(form_add_participation_by_person) }}
+
{{ form_end(form_add_participation_by_person) }}
diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php
index 5272b4aad..ad23e5655 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/PickUserDynamicType.php
@@ -43,6 +43,7 @@ class PickUserDynamicType extends AbstractType
$view->vars['uniqid'] = uniqid('pick_user_dyn');
$view->vars['suggested'] = [];
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
+ $view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0';
foreach ($options['suggested'] as $user) {
$view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']);
@@ -58,7 +59,9 @@ class PickUserDynamicType extends AbstractType
->setDefault('suggested', [])
// if set to true, only the id will be set inside the content. The denormalization will not work.
->setDefault('as_id', false)
- ->setAllowedTypes('as_id', ['bool']);
+ ->setAllowedTypes('as_id', ['bool'])
+ ->setDefault('submit_on_adding_new_entity', false)
+ ->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
}
public function getBlockPrefix()
diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js
index 6e939734e..6b33c0f52 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js
@@ -25,7 +25,9 @@ function loadDynamicPicker(element) {
null : [ JSON.parse(input.value) ]
)
suggested = JSON.parse(el.dataset.suggested),
- as_id = parseInt(el.dataset.asId) === 1;
+ as_id = parseInt(el.dataset.asId) === 1,
+ submit_on_adding_new_entity = parseInt(el.dataset.submitOnAddingNewEntity) === 1
+ label = el.dataset.label;
if (!isMultiple) {
if (input.value === '[]'){
@@ -40,6 +42,7 @@ function loadDynamicPicker(element) {
':picked="picked" ' +
':uniqid="uniqid" ' +
':suggested="notPickedSuggested" ' +
+ ':label="label" ' +
'@addNewEntity="addNewEntity" ' +
'@removeEntity="removeEntity">',
components: {
@@ -51,8 +54,10 @@ function loadDynamicPicker(element) {
types: JSON.parse(el.dataset.types),
picked: picked === null ? [] : picked,
uniqid: el.dataset.uniqid,
- suggested: suggested,
- as_id: as_id,
+ suggested,
+ as_id,
+ submit_on_adding_new_entity,
+ label,
}
},
computed: {
@@ -92,6 +97,10 @@ function loadDynamicPicker(element) {
}
}
}
+
+ if (this.submit_on_adding_new_entity) {
+ input.form.submit();
+ }
},
removeEntity({entity}) {
if (-1 === this.suggested.findIndex(e => e.type === entity.type && e.id === entity.id)) {
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
index 0a39718e2..75abc4fdd 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue
@@ -56,6 +56,10 @@ export default {
suggested: {
type: Array,
default: []
+ },
+ label: {
+ type: String,
+ required: false,
}
},
emits: ['addNewEntity', 'removeEntity'],
@@ -80,6 +84,10 @@ export default {
};
},
translatedListOfTypes() {
+ if (this.label !== '') {
+ return this.label;
+ }
+
let trans = [];
this.types.forEach(t => {
if (this.$props.multiple) {
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
index 1ff92fd5f..9c60028ad 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
@@ -257,7 +257,9 @@
data-multiple="{{ form.vars['multiple'] }}"
data-uniqid="{{ form.vars['uniqid'] }}"
data-suggested="{{ form.vars['suggested']|json_encode|escape('html_attr') }}"
- data-as-id="{{ form.vars['as_id'] }}">
+ data-as-id="{{ form.vars['as_id'] }}"
+ data-submit-on-adding-new-entity="{{ form.vars['submit_on_adding_new_entity'] }}"
+ data-label="{{ form.vars['label']|trans|escape('html_attr') }}">
{% endblock %}
{% block pick_postal_code_widget %}
diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php
index 94c625a38..71fd36225 100644
--- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php
+++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonDynamicType.php
@@ -42,6 +42,7 @@ class PickPersonDynamicType extends AbstractType
$view->vars['uniqid'] = uniqid('pick_user_dyn');
$view->vars['suggested'] = [];
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
+ $view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0';
foreach ($options['suggested'] as $person) {
$view->vars['suggested'][] = $this->normalizer->normalize($person, 'json', ['groups' => 'read']);
@@ -56,7 +57,9 @@ class PickPersonDynamicType extends AbstractType
->setDefault('compound', false)
->setDefault('suggested', [])
->setDefault('as_id', false)
- ->setAllowedTypes('as_id', ['bool']);
+ ->setAllowedTypes('as_id', ['bool'])
+ ->setDefault('submit_on_adding_new_entity', false)
+ ->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
}
public function getBlockPrefix()
diff --git a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php
index de233c360..e46e4544e 100644
--- a/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php
+++ b/src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdpartyDynamicType.php
@@ -42,6 +42,7 @@ class PickThirdpartyDynamicType extends AbstractType
$view->vars['uniqid'] = uniqid('pick_user_dyn');
$view->vars['suggested'] = [];
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
+ $view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0';
foreach ($options['suggested'] as $tp) {
$view->vars['suggested'][] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']);
@@ -56,7 +57,9 @@ class PickThirdpartyDynamicType extends AbstractType
->setDefault('compound', false)
->setDefault('suggested', [])
->setDefault('as_id', false)
- ->setAllowedTypes('as_id', ['bool']);
+ ->setAllowedTypes('as_id', ['bool'])
+ ->setDefault('submit_on_adding_new_entity', false)
+ ->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
}
public function getBlockPrefix()