CP form: add error class to lable --> NOT only input
Posted: Mon 24. May 2010, 01:02
I spent years and hours finding a solution for the following problem that:
with CP form you can add classes only to input fields.
And in case of errors:
a) the error messages appears solely - isolated.
b) the CSS class 'error' is applied only to input fields
Error tags are never applied to labels.
Because of that there are some limitations:
a) you only can take an affect on the styling of the input field
b) or the [isolated] error messages
but you cannot change or edit <label>
What do I want to have in case of errors:
a certain color of the label tag
Today I stumbled over the solution:
THAT'S THE WAY YOU CAN DO:
in your custom form template
I can't explain how it works - but it works well.
You need the input field have set marked 'required'.
Output HTML:
useful CSS now available:
Yeah, happy, palim, dingsbums-2-3...[4-music playing]
with CP form you can add classes only to input fields.
And in case of errors:
a) the error messages appears solely - isolated.
b) the CSS class 'error' is applied only to input fields
Error tags are never applied to labels.
Because of that there are some limitations:
a) you only can take an affect on the styling of the input field
b) or the [isolated] error messages
but you cannot change or edit <label>
What do I want to have in case of errors:
a certain color of the label tag
Today I stumbled over the solution:
THAT'S THE WAY YOU CAN DO:
in your custom form template
Code: Select all
<label for="email"[IF_ERROR] class="MYerror"[/IF_ERROR]>E-Mail<strong>*</strong></label>{email}
You need the input field have set marked 'required'.
Output HTML:
Code: Select all
<label for="email" class="MYerror">E-Mail<strong>*</strong></label><input type="text" name="email" id="email" value="" class="error" />
useful CSS now available:
Code: Select all
label.MYerror ....aus die maus