[eluser]newsun[/eluser]
Samus, this works and is what we already have in place more or less. Only thing is it requires a line item for the style of each field, where I should be able to do it more automatically if only I had access to the field name I use when setting up the rule in the first place.
[quote author="Samus" date="1333797184"][quote author="Aken" date="1333774184"]You'd have to extend CodeIgniter to include this functionality; it is not built in.[/quote]
Not necessarily.
This can be done quite simply:
e.g
Code:
$this->form_validation->set_rules('phone', 'Phone', 'trim|required');
$this->form_validation->set_message('required', '%s is Required');
And then in your view
Code:
<span <?php echo ($this->input->post() ? (form_error(('phone')) ? "<style>input[name='phone'] {border: 1px solid #a00; background-color: #faa;}</style>" : "") : ""); ?>"></span>
Checks to see if there is any POST data. If there is, it checks to see if there is an error for the 'phone' field, if there is an error it adds the required style.
[/quote]