CI Validation value-data


I use the validation class for a form.
Like in the example I use in the controller:

$rules['laufzeit'] = "exact_length[2]";
$rules['geldbetrag'] = "required|callback_betrag_check";
$rules['wagen'] = "required";
$rules['email']        = "required";

if ($this->validation->run() == FALSE)
    $this->layout->buildPage("versicherungsrechner/uebersicht", $data);
    $this->layout->buildPage("versicherungsrechner/uebersicht", $data);

and for the view I use:
//some code
//line 25 follows...
<input type="text" name="email" value="<?=$this->validation->email;?>" size="50" />

And the result of this is:
Quote:A PHP Error was encountered
Severity: Notice

Message: Undefined property: CI_Validation::$email

Filename: versicherungsrechner/uebersicht.php

Line Number: 25

I have no more idea how to fix fact it´s like in the example.
Does someone have an idea??



just a guess but $this->validation->email probably requires you to have set_fields() so

$fields['email'] = "Email";

thx for your suggestion, but unfortunately that doesn´t work...the same error msg...

Is there ever a point in your logic where you display the view without having called set_fields() in your controller? like when you initially visit the page or something like that.

I´m not sure if I understand you right.
I never use set_fields() in my controller before (it´s also the first time I use the validation-class)or what did you mean?

OK I believe in order to access $this->validation->my_field you must first have called set_fields with an array containing 'my_field'
What I meant is make sure you're logic is structured in such a way that you every time you call you're view you've already called set_fields.

ok, now I understand Wink
I use set_fields before display the datas, but input-text doesn´t work.
I also have a dropdown and radiobuttons and there is no problem to use it(also without set_fields), for example:

<?= $this->validation->set_select('laufzeit', '12'); ?> or <?= $this->validation->set_radio('wagen', 'gebraucht'); ?>

$this->validation->set_select(); and $this->validation->set_radio(); are functions (actually they're class methods) presumably defined in the class whereas $this->validation->my_field is a class attribute defined by you (by calling set_fields).

yes you´re right.
I also set the select-names in set_fields, what was wrong.

Now I change some code and now it´s working. It´s like you said, I have to use set_fields otherwise I will get an error (but it´s curious, because I use it after your first post...)
Well, it doesn´t matter anymore, big thanks to you :-)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.