Skip to content

Commit 2b579d8

Browse files
authored
Merge pull request #5114 from 3liz/backport-5107-to-master
[Backport master] Fix edition form child with relation
2 parents f004d06 + 020556e commit 2b579d8

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

assets/src/legacy/edition.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,19 +1617,13 @@ var lizEdition = function() {
16171617
} else {
16181618
var select = form.find('select[name="'+relationRefField+'"]');
16191619
if( select.length == 1 ){
1620-
// Disable the select, the value will be stored in an hidden input
1621-
select.val(parentFeatProp)
1622-
.attr('disabled','disabled');
1623-
// Create hidden input to store value because the select is disabled
1624-
var hiddenInput = $('<input type="hidden"></input>')
1625-
.attr('id', select.attr('id')+'_hidden')
1626-
.attr('name', relationRefField)
1627-
.attr('value', parentFeatProp);
1628-
form.find('div.jforms-hiddens').append(hiddenInput);
1629-
// Disable required constraint
1630-
jFormsJQ.getForm(form.attr('id'))
1631-
.getControl(relationRefField)
1632-
.required=false;
1620+
// select the option via jquery (and fire event with "change", will update depending controls)
1621+
select.val(parentFeatProp).change();
1622+
// create a disabled input with selected option value (will look alike a select)
1623+
let readOnlyInput4Select = $('<input type="text" disabled value="'+$("select[name="+relationRefField+"] option:selected").html() +'" />');
1624+
select.parent().append(readOnlyInput4Select);
1625+
// hide the select, we don't want to see it, but it need to still be enable for controls that depends of its value
1626+
select.addClass('hide');
16331627
} else {
16341628
var input = form.find('input[name="'+relationRefField+'"]');
16351629
if( input.length == 1 && input.attr('type') != 'hidden'){

tests/end2end/cypress/integration/feature_toolbar-ghaction.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ describe('Feature Toolbar in popup', function () {
442442

443443
cy.wait(300)
444444

445-
// Parent_id is disabled in form when edition is started from parent form
446-
cy.get('#jforms_view_edition_parent_id').should('be.disabled')
445+
// Parent_id is hidden in form when edition is started from parent form
446+
cy.get('#jforms_view_edition_parent_id').should('have.class', 'hide');
447447

448448
// Parent_id input should have the value 2 selected
449449
cy.get('#jforms_view_edition_parent_id').find('option:selected').should('have.value', '2');
@@ -459,8 +459,8 @@ describe('Feature Toolbar in popup', function () {
459459

460460
cy.wait(300)
461461

462-
// Parent_id is disabled in form when edition is started from parent form
463-
cy.get('#jforms_view_edition_parent_id').should('be.disabled')
462+
// Parent_id is hidden in form when edition is started from parent form
463+
cy.get('#jforms_view_edition_parent_id').should('have.class', 'hide');
464464

465465
// Parent_id input should have the value 2 selected
466466
cy.get('#jforms_view_edition_parent_id').find('option:selected').should('have.value', '2');

0 commit comments

Comments
 (0)