Is it possible through the UI to make a parameter for a component optional? I.e. I'd like to allow my users to optionally provide some text, but so far I've only been able to make it required.
If I can't do it through the UI, can I use a hook or something to do it in a module? My plan is to package my rule up with Features, so adding custom code isn't a big deal, once I know what I need to modify.
Thanks.
Colin
Comments
Comment #1
dasjoi don't think that's possible yet. sounds like a feature request
Comment #2
colin_young commentedThat was my conclusion also. I've solved the problem in the interim with a bit of javascript to provide a suitable default value in the event the user leaves it blank.
Comment #3
mitchell commentedTagging
Comment #4
fagoIt's already possible, but it's not yet exposed to the UI.
Just add the "optional => TRUE" flag to the variable in your rule / json export.
Comment #5
nicolas bouteille commentedWould love to see it in the UI as well
Comment #6
nicolas bouteille commentedTried to export / import my rule adding the tag like that :
"USES VARIABLES" : {
"mission" : { "label" : "Mission", "type" : "text", "optional => TRUE" },
Got an error message saying that the pasted code cannot be analyzed.
Tried this instead :
"USES VARIABLES" : {
"mission" : { "label" : "Mission", "type" : "text", "optional" : "true" },
Import went well but the parameter does not seem to be considered as optional because I still get the message
2.559 ms The variable or parameter mission is empty.
3.458 ms Unable to evaluate action ...
What did I do wrong ?
Comment #7
nicolas bouteille commentedLooks like if I add "allow null" and "default value" as suggested in this thread http://groups.drupal.org/node/233883
"USES VARIABLES" : {
"mission" : { "label" : "Mission", "type" : "text", "optional" : "true", "allow null" : "true", "default value" : "null" },
then it works. Now I have other errors but this seem to work
Switching back to feature request to have it in the UI
Comment #8
nicolas bouteille commentedMy modifications are gone as soon as I save the rule again from the UI... I should have expected it... definitely need it in the UI!
Comment #9
decipheredDuplicate of #1704282: Add "required" (allow null/empty) option to component parameters
Comment #10
geek-merlin