Welcome Guest, Not a member yet? Register   Sign In
Undocumented use of $this->validation->error_string
#1

[eluser]Bramme[/eluser]
After using CI for about 4 months or so, today I figured something silly out and I wished I learned about it a lot earlier.

When working with forms and validation, most of the time, I just return to the original form (when the form is succesfully submitted) but display an additional line.
Code:
if ($this->db->insert()) $msg = 'success!';
My views often looked like this then
Code:
<form action="/admin/news/new_item" method="post">
<?=$this->validation->error_string?>
<? if (isset($msg)) echo $msg; ?>

Today I realised, since CI is also php 4 compatible there's no difference between public and private vars (or functions for that matter), so I could perfectly well use
Code:
if ($this->db->insert()) $this->validation->error_string = 'success!';

This means I don't have to add that extra lines in my view, which is a lot cleaner and the whole practice is imo semantically correcter.

The only thing I'm annoyed by now is the error_string term... I'd rather see smth like feedback_string, but that's only a small thing.

I just wanted to post this and hope it would get documented, that way other people might be helped earlier by it.


Messages In This Thread
Undocumented use of $this->validation->error_string - by El Forum - 08-06-2008, 06:55 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-06-2008, 07:06 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-06-2008, 07:44 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-06-2008, 08:04 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-06-2008, 08:28 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-07-2008, 02:30 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-07-2008, 03:47 AM
Undocumented use of $this->validation->error_string - by El Forum - 08-07-2008, 03:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB