Hello monks and gurus, I am in need of help in formatting the dependencies of my Data::FormValidator profile. My skill on using Perl is just average or below that and I easily get lost on confusing routines. I need your kind inputs.
Just an overview, I have the three fields described below in my form:
<select name="f_course">
<option value="Select Course">Select Course</option>
<option value="Course A">Course A</option>
<option value="Course B">Course B</option>
</select>
<select name="f_month">
<option value="Select Month">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
........
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="f_year">
<option value="Select Year">Select Year</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
........
<option value="2003">2003</option>
<option value="2002">2002</option>
</select>
The above 3 fields are actually optional fields. However, if either of the 3 fields is filled up, the remaining 2 fields would be required also. Example: if the user selects "Course A" from the f_course field, then he must also select the proper f_month and f_year, otherwise an error will be returned prompting the user to complete these 3 fields.
The first option on each of the 3 fields is something like "Select Course" or "Select Month" or "Select Year". If this is the returned value for the corresponding field, this will be treated similar to an empty field (thereby requiring the user to make a valid selection... if in case one of the 3 fields is filled up).
I am hoping you can help me do the above routine that can be incorporated as a dependency...
my $profile = {
optional => [qw( f_course f_month f_year )],
required => [qw( f_a, f_b )],
dependencies => {
# If f_course is entered, make f_month and f_year required
# Or if f_month is entered, make f_course and f_year required
# Or if f_year is entered, make f_course and f_month required
},
};
... where I need only to monitor the returned
$obj->has_missing.
Thanks everyone for even taking the time to read this. Your inputs will be very much appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.