> There is boolean type
>
> Example
>
> <field name="Active" key="active" type="boolean"/>
>
> Here is a macro that adds a hidden value that intake will use in the
> event the box is unchecked. It would be used similar to
> #booleanCheckbox($intake.Attribute.mapTo($attribute).Active)
>
> #macro ( booleanCheckbox $booleanField )
> <input type="checkbox" name="$booleanField.Key" value="true"
> #if ($booleanField.Value) checked #end />
> <input type="hidden" name="$booleanField.ValueIfAbsent"
> value="false" />
> #end
Thanks - that was very helpful.
> Date types still need to be added. Please help with this if you have
> the need.
I have worked up an interim solution whereby I add a pair of
wrapper methods around the date in the peer class thus:
public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance();
public String getStartDateString()
{
return CmesConstants.DATE_FORMAT.format(getStartDate());
}
public void setStartDateString(String dateString)
{
try {
setStartDate(CmesConstants.DATE_FORMAT.parse(dateString));
}
catch (ParseException ex) {
Log.error("setStartDate(): Unable to parse dateString: " + dateString);
}
}
In my intake file I use the wrapper instead of the real attribute thus:
<field name="StartDate" key="sdate" type="String" mapToProperty="StartDateString">
<rule name="required" value="true">Please enter a start date.</rule>
<rule name="mask" value="^[0-3]?\d/[01]?\d/[29][09]\d\d$">Please enter a sensible
date ("dd/mm/yyyy").</rule>
</field>
Note that the date format I am using here is that suitable
for Australia. The mask allows for dates from 2000 through
2099 as well as the date 31/12/9999 which is my maximum
date.
While not perfect, this solution should be adequate for my
current application. I am not confident enough yet to dive
in and have a go at writing a proper date validator. It looks
like Ian might be on to this already.
> john mcnally
Thanks John,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]