Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edition form child with relation #5107

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions assets/src/legacy/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -1617,19 +1617,13 @@ var lizEdition = function() {
} else {
var select = form.find('select[name="'+relationRefField+'"]');
if( select.length == 1 ){
// Disable the select, the value will be stored in an hidden input
select.val(parentFeatProp)
.attr('disabled','disabled');
// Create hidden input to store value because the select is disabled
var hiddenInput = $('<input type="hidden"></input>')
.attr('id', select.attr('id')+'_hidden')
.attr('name', relationRefField)
.attr('value', parentFeatProp);
form.find('div.jforms-hiddens').append(hiddenInput);
// Disable required constraint
jFormsJQ.getForm(form.attr('id'))
.getControl(relationRefField)
.required=false;
// select the option via jquery (and fire event with "change", will update depending controls)
select.val(parentFeatProp).change();
// create a disabled input with selected option value (will look alike a select)
let readOnlyInput4Select = $('<input type="text" disabled value="'+$("select[name="+relationRefField+"] option:selected").html() +'" />');
select.parent().append(readOnlyInput4Select);
// hide the select, we don't want to see it, but it need to still be enable for controls that depends of its value
select.addClass('hide');
} else {
var input = form.find('input[name="'+relationRefField+'"]');
if( input.length == 1 && input.attr('type') != 'hidden'){
Expand Down
8 changes: 4 additions & 4 deletions tests/end2end/cypress/integration/feature_toolbar-ghaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ describe('Feature Toolbar in popup', function () {

cy.wait(300)

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

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

cy.wait(300)

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

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