Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
how to "switch" mandatory fields
meikel
Hi,
in the templating script section of my WF I have some TAGs
wf_decider: here I decide some stuff with checkboxes
wf_field1...wf_field3
When I now decide box 1 wf_field1 must be filled.
When I decide box 2 wf_field2 must be filled. and so on...
How can I realize "dynamic" checks
regards
meikel
Find more posts tagged with
Comments
Adam Stoller
I'm not sure what you're asking - could you perhaps post the relevent section of code with a use-case scenario and actions/desired effects?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
meikel
OK, in this code snippet both (wf_field1 and wf_field2) are required:
wf_decider =>
[ html => "<input type=\"radio\" value=\"1\" checked>one</input><br />" .
"<input type=\"radio\" value=\"2\">two</input><br />",
label => "make a decision",
is_required => 'true',
],
wf_field1 =>
[ html => "<textarea rows='5' cols='40'></textarea>",
label => "field one",
is_required => 'true',
],
wf_field2 =>
[ html => "<textarea rows='5' cols='40'></textarea>",
label => "field two",
is_required => 'true',
],
What I am looking for is a "dynamical requirement".
The wf_field1 must required, when in wf_decider the first option was selected.
Understood?
meikel
Migrateduser
I don't think you can do this using TAG_info - your TAG_info section is only executed one time. In order to do what you want, I believe you'd want to use a cgitask as your start task and base it's prompts on what was entered in your job UI screen. But beware if you have a cgitask as your start task in your workflow - the TeamSIte view will not be automatically directed to your ToDo list after they finish entering their data. That can cause some confusion with users who are used to having their view change to the ToDo list after they start a job.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
jbonifaci
You could try using the valid_input option for wf_field1 and wf_field2:
wf_field1 =>
[ html => "<textarea rows='5' cols='40'></textarea>",
label => "field one",
is_required => 'false',
valid_input => 'validate_wf_field1()'
],
wf_field2 =>
[ html => "<textarea rows='5' cols='40'></textarea>",
label => "field two",
is_required => 'false',
valid_input => 'validate_wf_field2()'
],
then add the validate functions to your wft:
sub validate_wf_field1
{
if (__VALUE__('wf_decider') == 1)
{
return 1;
}
return 0;
}
}
sub validate_wf_field2
{
if (__VALUE__('wf_decider') == 2)
{
return 1;
}
return 0;
}
}
Migrateduser
The
valid_input
element simply determines whether the input entered
for that particular field
is valid and if it returns 0 then some kind of message will be printed out adjacent
to that particular field
. As far as I know there is no way to associate a field in the TAG_info section based on the entered data from another field.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
jbonifaci
Dave,
The validation is run server side, so you have access to all of the field values. I have done this several times in the past.
Jeff
Migrateduser
But how does the validator for field B affect the display of the field B prompt? The validator only applies once you enter the data - field B already appears. What this guy wants to do is prevent field B from even appearing based on the input of field A. That's a trick...
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
james1
I recall attempting something similar to what Jeff proposed, but instead of doing it on the input validation, I did it on the tag HTML, so that the tag HTML was either "<input type='hidden' ...>" or a normal input. However, I have a feeling that this didn't work, that there was a chicken-and-egg problem, i.e., at the time that I was evaluating the value of my tag -- that is to say, when it came time to get the tag's HTML -- the tag had not yet been given its value from the form inputs, or something like that. It might be worth a try, if anyone is willing, because my memory could be wrong about this.
-- James
--
James H Koh
Interwoven Engineering
dsrv_log.txt
platform_log.txt
jbonifaci
He never said he didn't want them not to be displayed or hidden based on what the value of wf_decider. That can easily be done with javascript. What he wanted was to have the fields required based on what the value of wf_decider. That is what the valid_input code I posted will do.
Migrateduser
Maybe you're right. It's hard to tell exactly what he wants when I read his posts.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com