CodeIgniter Forums
Form Errors - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Errors (/showthread.php?tid=22409)



Form Errors - El Forum - 09-08-2009

[eluser]dippy[/eluser]
is there a simple way to use an error icon next to the input field that has the error but then show the error message somewhere else? say at the top of the page?

right now i am using the validation class.

Code:
$this->validation->set_message('check_service', 'Please select a service');

and then using this to print the message

Code:
$this->validation->serviceType_error;


Thanks in advance


Form Errors - El Forum - 09-08-2009

[eluser]bretticus[/eluser]
[quote author="dippy" date="1252461982"]is there a simple way to use an error icon next to the input field that has the error but then show the error message somewhere else? say at the top of the page?[/quote]

Yes, checkout the manual about showing individual errors.

To do the icon, just change your error delimiters.

Use a variant of validation_errors() to show your errors at the top.

Code:
&lt;?php echo validation_errors('<div class="error">', '</div>'); ?&gt;



Form Errors - El Forum - 09-08-2009

[eluser]dippy[/eluser]
[quote author="bretticus" date="1252468876"][quote author="dippy" date="1252461982"]is there a simple way to use an error icon next to the input field that has the error but then show the error message somewhere else? say at the top of the page?[/quote]

Yes, checkout the manual about showing individual errors.

To do the icon, just change your error delimiters.

Use a variant of validation_errors() to show your errors at the top.

Code:
&lt;?php echo validation_errors('<div class="error">', '</div>'); ?&gt;
[/quote]


Awesome thanks for your help.


Form Errors - El Forum - 09-16-2009

[eluser]dippy[/eluser]
i cannot get the text to stop coming up over the icon...

i have the error printing at the top of the page and i am trying to have an "x" icon show up next to the form field the user forgot.

here is the code for just the form. my files are pretty big to put it all up...

controller:
Code:
if($service != 'none'){
                return TRUE;
            }else{
                $this->form_validation->set_message('check_service', 'Please select a service');
                return FALSE;
            }

view:
Code:
&lt;? echo validation_errors();?&gt;
                   <div class="searchBoxError">
                        &lt;?php echo form_error('serviceType', '<div class="errorIcon">', '</div>'); ?&gt;
                   </div>
                    <div class="searchBoxRight">
                        <div class="searchBoxHeader"></div>
                        <br />
                        <select class="searchTxtb" name="serviceType" id="serviceType">
                            <option value="none" selected="selected">Select Service...</option>
                                &lt;?php foreach($siteServices->result() as $service): ?&gt;
                <option value="&lt;?=strtolower($service->service);?&gt;" &lt;?=set_select('serviceType', strtolower($service->service)) ?&gt; >&lt;?=$service->service;?&gt;</option>
                &lt;?php endforeach; ?&gt;
                        </select>
                      </div>

i have the error text "Please select a service" showing up at the top AND over top of the errorIcon div.

is there a way to just show the icon and no text?

thanks in advance.