Welcome Guest, Not a member yet? Register   Sign In
Noob, checking in view to see if a data item exists
#1

[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.
#2

[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’;
Is it this what you are after?
#3

[eluser]Michael Wales[/eluser]
Using the code example you provided, you would change your view code to:

Code:
<?php
if(isset($error))
{
  echo 'Error:' . $error;
}
?>
#4

[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
#5

[eluser]tobben[/eluser]
All of us started knowing jack shait on PHP, so just keep up the good work Smile

Yes, CI is great in many ways.




Theme © iAndrew 2016 - Forum software by © MyBB