@@ -1063,7 +1063,6 @@ def create_inputs(tool, model, **kwargs):
1063
1063
fmt_select_attrib = OrderedDict ([
1064
1064
("name" , param .name + "_type" ),
1065
1065
("type" , "select" ),
1066
- ("optional" , "false" ),
1067
1066
("label" , f"File type of output { param .name } ({ param .description } )" )
1068
1067
])
1069
1068
fmt_select = add_child_node (parent_node , "param" , fmt_select_attrib )
@@ -1241,11 +1240,21 @@ def create_param_attribute_list(param, model, supported_file_formats, parameter_
1241
1240
optional = False
1242
1241
else :
1243
1242
optional = not param .required
1244
- param_node .attrib ["optional" ] = str (optional ).lower ()
1245
1243
1246
- if is_selection_parameter (param ):
1247
- if param .is_list :
1248
- param_node .attrib ["multiple" ] = "true"
1244
+ # set multiple for select parameters if needed
1245
+ # also set optional if it's not the default
1246
+ # - for select with multiple=true optional defaults to true, i.e. we set it if the parameter is not optional
1247
+ # - never set it for bool
1248
+ # - otherwise the default is false, i.e. we set the attribute if the parameter is optional
1249
+ if is_selection_parameter (param ) and param .is_list :
1250
+ param_node .attrib ["multiple" ] = "true"
1251
+ if not optional :
1252
+ param_node .attrib ["optional" ] = str (optional ).lower ()
1253
+ if param_type == "boolean" :
1254
+ pass
1255
+ else :
1256
+ if optional :
1257
+ param_node .attrib ["optional" ] = str (optional ).lower ()
1249
1258
1250
1259
# check for parameters with restricted values (which will correspond to a "select" in galaxy)
1251
1260
if param .restrictions is not None or param_type == "boolean" :
@@ -1278,8 +1287,8 @@ def create_param_attribute_list(param, model, supported_file_formats, parameter_
1278
1287
if is_default (choice , param ):
1279
1288
option_node .attrib ["selected" ] = "true"
1280
1289
1281
- # add validator to check that "nothing selected" is not seletcedto mandatory options w/o default
1282
- if param_node .attrib [ "optional" ] == " False" and (param .default is None or type (param .default ) is _Null ):
1290
+ # add validator to check that "nothing selected" is not seleted to mandatory options w/o default
1291
+ if param_node .attrib . get ( "optional" , "false" ) in [ "false" , " False"] and (param .default is None or type (param .default ) is _Null ):
1283
1292
validator_node = add_child_node (param_node , "validator" , OrderedDict ([("type" , "expression" ), ("message" , "A value needs to be selected" )]))
1284
1293
validator_node .text = 'value != "select a value"'
1285
1294
@@ -1412,7 +1421,7 @@ def create_param_attribute_list(param, model, supported_file_formats, parameter_
1412
1421
when_no = add_child_node (conditional , "when" , attributes = {"value" : "no" })
1413
1422
when_no .append (copy .deepcopy (param_node ))
1414
1423
when_yes = add_child_node (conditional , "when" , attributes = {"value" : "yes" })
1415
- param_node .attrib ["multiple" ] = "false"
1424
+ del param_node .attrib ["multiple" ]
1416
1425
when_yes .append (param_node )
1417
1426
return conditional
1418
1427
0 commit comments