N°8772 - Turbo + Collections WIP

This commit is contained in:
Eric Espie
2025-11-05 11:19:03 +01:00
parent 8fdad7997e
commit 9ea546ebf6
4 changed files with 20 additions and 5 deletions

View File

@@ -3,12 +3,28 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
function triggerTurbo(el) {
let sFormName = el.form.getAttribute("name");
el.form.querySelector(`[name="${sFormName}[_turbo_trigger]"]`).value = el.getAttribute('name');
el.form.setAttribute('novalidate', true);
el.form.requestSubmit();
console.log('Auto submitting form due to change in field ' + el.getAttribute('name'));
}
function addFormToCollection(e) {
const collectionHolder = document.querySelector('.' + e.currentTarget.dataset.collectionHolderClass);
const item = document.createElement('div');
item.style.marginTop = '20px';
item.innerHTML = collectionHolder
.dataset
.prototype
.replace(
/__name__/g,
collectionHolder.dataset.index
);
collectionHolder.appendChild(item);
collectionHolder.dataset.index++;
console.log(collectionHolder.dataset.index);
}

View File

@@ -31,7 +31,6 @@ class FormType extends AbstractType
'name' => $oChild->GetName(),
'added' => $oChild->IsAdded(),
'id' => $oChild->GetIdentifier(),
'path' => $oFormChild->getPropertyPath(),
];
}
else{

View File

@@ -48,7 +48,7 @@
{%- block form_rows -%}
{% for block in blocks %}
<div id="block_{{ block.id }}" class="ibo-field ibo-content-block ibo-block ibo-field-small">
<div id="turbo_{{ block.id }}" class="ibo-field ibo-content-block ibo-block ibo-field-small">
{% if block.added == 1 %}
{{ form_row(form[block.name]) }}
{% else %}

View File

@@ -2,7 +2,7 @@
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% for sBlockIdentifier, oBlockToRedraw in blocks_to_redraw %}
{% UITurboUpdate Standard { sTarget: "block_" ~ sBlockIdentifier} %}
{% UITurboUpdate Standard { sTarget: "turbo_" ~ sBlockIdentifier} %}
{% if oBlockToRedraw is not null %}
{{ form_row(oBlockToRedraw) }}
{% endif %}