Noob, checking in view to see if a data item exists - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Noob, checking in view to see if a data item exists (/showthread.php?tid=6604) |
Noob, checking in view to see if a data item exists - El Forum - 03-05-2008 [eluser]happs74[/eluser] Hi, I'm a noob in both PHP/CI, so I'm going to play my ask-one-stupid-question-free card now. I have a view with a form with all the validation stuff in it, in one particular case I'd like to add an additional message to it. So I have 5 calls that do $this->load->view('bigform'); and I want to do one that does $data['error'] = 'Its all gone a bit Pete Tong'; $this->load->view('bigform',$data); I reckon in my view I'd need something like <?php if(is_set('error') { echo 'Error:'.$error; } ?> but I guess it's not going to work like that. Anyone point me in the right direction, I guess there must be some sort of ability to do this as I'd imagine there are a lot of cases where you'd want a view that you can send different blobs of data to and for it to be able to pick'n'choose what to display depending on what is available. or maybe not. Muchos gracias in advance. Noob, checking in view to see if a data item exists - El Forum - 03-05-2008 [eluser]xwero[/eluser] If you want the additional message attached to the validation error_string you could do Code: $this->validation->error_string = ‘Its all gone a bit Pete Tong’; Noob, checking in view to see if a data item exists - El Forum - 03-05-2008 [eluser]Michael Wales[/eluser] Using the code example you provided, you would change your view code to: Code: <?php Noob, checking in view to see if a data item exists - El Forum - 03-05-2008 [eluser]happs74[/eluser] Cheers, that did the job, my lack of knowledge of php showing there a bit. Still it's quite impressive how much I can do in CI with next to no php skillz. Ta, Mark Noob, checking in view to see if a data item exists - El Forum - 03-05-2008 [eluser]tobben[/eluser] All of us started knowing jack shait on PHP, so just keep up the good work Yes, CI is great in many ways. |