@@ -1617,19 +1617,13 @@ var lizEdition = function() {
1617
1617
} else {
1618
1618
var select = form . find ( 'select[name="' + relationRefField + '"]' ) ;
1619
1619
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' ) ;
1633
1627
} else {
1634
1628
var input = form . find ( 'input[name="' + relationRefField + '"]' ) ;
1635
1629
if ( input . length == 1 && input . attr ( 'type' ) != 'hidden' ) {
0 commit comments