CodeIgniter Forums

Full Version: I want validation_errors with <br>, but just one <br> between errors message.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]frankabel[/eluser]
Hi all,

How can I archieve that the out of my
Code:
validation_errors
function put just one
Code:
<br>
tag between the error messages?

I test with something like
Code:
validation_errors('<br>')
and nothing,
Code:
<p></p>
tags are inserted between error messages, and I just want one
Code:
<br>
tag as separator.

Thanks
Frank

El Forum

[eluser]rochellecanale[/eluser]
Just do this code:
Example

Username &lt;input type='text' name='username'&gt;
&lt;?php echo br(); ?&gt;
&lt;?php echo validation_errors(); ?&gt;

You have to set the html helper
$this->load->helper('html');

or set it manually in html code
Example
Username &lt;input type='text' name='username'&gt;&lt;br />
&lt;?php echo validation_errors(); ?&gt;

El Forum

[eluser]frankabel[/eluser]
Seem to me that I don't explain myselfWink

What I want is that the separation tag be another one than <p></p> between the multiple erros message that validation_errors() print, so in some way I must control what validation_errors() does, cos I can't inser br between the each message cos validation_errors print all messages as a whole. I tested passing first parameter (separation tag) to validation_errors() and don't work, the problem is that if you don't pass the open and close tag, the function still add <p>, and that break my HTML.

El Forum

[eluser]CroNiX[/eluser]
Looking at the code for validation_errors($open, $close), it seems if you pass an empty open or close string it defaults back to whatever the default is for $form_validation->error_prefix and $form_validation->error_suffix, which is a p tag, or whatever they have been set to using set_error_delimiters().

So it seems, you should use
Code:
$this->form_validation->set_error_delimiters('', '<br />');
to set those defaults and then this should probably work.

Code:
echo validation_errors('', '<br>');

El Forum

[eluser]frankabel[/eluser]
Thanks a lot!

I hope this bug get fixed in future CI versions.

Thanks again.
Frank