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

dasjo’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Component: User Interface » User interface

i don't think that's possible yet. sounds like a feature request

colin_young’s picture

Category: support » feature

That 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.

mitchell’s picture

Issue tags: +UX

Tagging

fago’s picture

It's already possible, but it's not yet exposed to the UI.

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.

Just add the "optional => TRUE" flag to the variable in your rule / json export.

nicolas bouteille’s picture

Component: User interface » User Interface

Would love to see it in the UI as well

nicolas bouteille’s picture

Category: feature » support

Tried 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 ?

nicolas bouteille’s picture

Category: support » feature

Looks 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

nicolas bouteille’s picture

My 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!

deciphered’s picture

Status: Active » Closed (duplicate)
geek-merlin’s picture