blankenb
Posts: 125
|
Posted: 06/26/2004, 10:54 AM |
|
(Courtesy of Yes Support) When a field validation fails an error is displayed at the top of the form it would be nice if the background color of the problematic field could also be changed to make it easier for the form user to find the error field.
This can be done via custom template variables. When error occurrs for a given field you can use Error Theme class for its table cell, e.g. for Olive Theme it is
class="OliveErrorDataTD"
To implement it add template variable to <td> tag:
<td {error_class} class="OliveFieldCaptionTD">Project Id </td>
and in Before Show event of a form check the field error string. If it is not empty substitute template variable with a class definition:
global $Tpl;
if (strlen($form_name->field_name->Errors->ToString()))
$Tpl->SetVar("error_class","class=\"OliveErrorDataTD\"");
else
$Tpl->SetVar("error_class","");
|
|
|
DonB
|
Posted: 06/26/2004, 7:12 PM |
|
The way I do this might seem more understandable to you since it avoids
working with the template object directly:
In the grid (anywhere is fine), create a label named {error_class}. Now,
within the HTML panel, relocate the string {error_class} as shown in the
original example.
Now, all you have to do is set the label's Value property to
"class='OliveErrorDataTD'" or "class='OliveFieldCaptionTD'", depending on
whether there was an error or not.
This technique works for any special attributes you want to manipulate in
HTML tags, not just changing the Class. An interesting one would be links -
changing the "target=_blank", etc. - so you have the option of opening them
in new windows or the same window, even different panels of a frameset.
--
DonB
logging at http://www.gotodon.com/ccbth, and blogging at http://ccbth.gotodon.net
"blankenb" <blankenb@forum.codecharge> wrote in message
news:540ddb86b79a48@news.codecharge.com...
> (Courtesy of Yes Support) When a field validation fails an error is
displayed
> at the top of the form it would be nice if the background color of the
> problematic field could also be changed to make it easier for the form
user to
> find the error field.
>
>
> This can be done via custom template variables. When error occurrs for a
given
> field you can use Error Theme class for its table cell, e.g. for Olive
Theme it
> is
> class="OliveErrorDataTD"
>
> To implement it add template variable to <td> tag:
> <td {error_class} class="OliveFieldCaptionTD">Project Id </td>
>
> and in Before Show event of a form check the field error string. If it is
not
> empty substitute template variable with a class definition:
> global $Tpl;
> if (strlen($form_name->field_name->Errors->ToString()))
> $Tpl->SetVar("error_class","class=\"OliveErrorDataTD\"");
> else
> $Tpl->SetVar("error_class","");
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
|