In the preceding example, we displayed errors one by one at the top of the HTML page; however, you may wish to display each individual error closer to the form element to which it refers.
We're going to amend the /path/to/codeigniter/application/views/new_record.php
file.
Amend the code to reflect the following (changes in bold):
<?php echo form_open('form/submit_form') ; ?> <?php if (validation_errors()) : ?> <h3>Whoops! There was an error:</h3> <?php endif; ?> <table border="0" > <tr> <td>First Name</td> <?php if (form_error('first_name')) : ?> <?php echo form_error('first_name') ; ?> <?php endif ; ?> <td><?php echo form_input(array('name' => 'first_name', 'id' => 'first_name', 'value' => set_value('first_name', ''), 'maxlength' => '100', 'size' => '50', 'style'...