File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 3737 || $ _REQUEST ['dropdown_itemtype ' ] == '0 '
3838 || !class_exists ($ _REQUEST ['dropdown_itemtype ' ])) {
3939 Dropdown::showFromArray (
40- 'dropdown_default_value ' ,
40+ 'dropdown_default_value ' ,
4141 [], [
4242 'display_emptychoice ' => true
4343 ]
4444 );
4545} else {
46+ $ itemtype = $ _REQUEST ['dropdown_itemtype ' ];
4647 $ question = new PluginFormcreatorQuestion ();
4748 $ question ->getFromDB ((int ) $ _REQUEST ['id ' ]);
48- $ defaultValue = isset ($ question ->fields ['default_values ' ])
49+ $ defaultValue = isset ($ question ->fields ['default_values ' ])
4950 ? $ question ->fields ['default_values ' ]
5051 : 0 ;
51- Dropdown::show ($ _REQUEST ['dropdown_itemtype ' ], [
52+
53+ $ options = [
5254 'name ' => 'dropdown_default_value ' ,
5355 'rand ' => mt_rand (),
5456 'value ' => $ defaultValue ,
55- ]);
57+ ];
58+ if ($ itemtype == Entity::class) {
59+ $ options ['toadd ' ] = [
60+ -1 => Dropdown::EMPTY_VALUE ,
61+ ];
62+ }
63+ Dropdown::show ($ itemtype , $ options );
5664}
Original file line number Diff line number Diff line change @@ -253,7 +253,16 @@ public function displayField($canEdit = true) {
253253
254254 $ dparams ['condition ' ] = $ dparams_cond_crit ;
255255
256- $ dparams ['display_emptychoice ' ] = ($ this ->question ->fields ['show_empty ' ] !== '0 ' );
256+ $ dparams ['display_emptychoice ' ] = false ;
257+ if ($ itemtype != Entity::class) {
258+ $ dparams ['display_emptychoice ' ] = ($ this ->question ->fields ['show_empty ' ] !== '0 ' );
259+ } else {
260+ if ($ this ->question ->fields ['show_empty ' ] !== '0 ' ) {
261+ $ dparams ['toadd ' ] = [
262+ -1 => Dropdown::EMPTY_VALUE ,
263+ ];
264+ }
265+ }
257266
258267 $ emptyItem = new $ itemtype ();
259268 $ emptyItem ->getEmpty ();
You can’t perform that action at this time.
0 commit comments