• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
form validation error

Hello world !!

I work on a website in codeigniter of course.

I search a method to print an error of a field of a form.

My fields is generate automatically with a buckle for like that:
echo "&lt;input id='field".$i."'&gt;";

Of course, the rules and fields sets are corrects.
Only the write errors don't work.

The version of my codeigniter used only allow me to use this syntax:

Obviously, i can't use $this->validation->field$i_error;

I find this syntax but isn't work :
$objectName = 'this'; //case sensitive.
$anotherObject = 'validation';//case sensitive
$functionName = 'field'.$i;

echo $$objectName->{$anotherObject}->{$functionName}();

Would come out the right syntax to do that ?
Please help, thank's in advance

PS : sorry for my grammar' errors.

oop's my mind get jumbled up by reading u'r question. Can u show u'r CONTROLLER code & VIEW code. Show that we can check it a bit properly...

[eluser]Federico Baña[/eluser]
I was having the same error on a project I was doing just for myself, where I wrote &lt;?php echo set_value( 'field' ); ?&gt; but nothing happened.

If you are using $this->validation->, you need to upgrade your version of CI, as that has been deprecated from the last 2 releases of CI. Please use the code button in the editor when posting code, so we can copy and paste it. Try:
&lt;?php echo validation_errors();?&gt;

&lt;?php for($i=1; $i < $num_dest; $i++);?&gt;
&lt;input name="field&lt;?php echo $i;?&gt;" type="text" value="&lt;?php echo set_value('field'.$i);?&gt;" /&gt;
&lt;?php endfor; ?&gt;

Make sure you are setting your validation rules in your controller.

In fact, i changed my CI's version to the last to do what i wanted to do and it's working !!
So now, i can do it easyly and quickly using this syntax :
'label'=>'my label',

and : $this->form_validation->set_rules($config);
it's cleanest !!
Thank's all for u'r answer !

ps : @mi6crazyheart : sorry for my language, i'm learning English...

Wow!!! it's great that u've finally solved u'r problem. By d way, about your English , it's my inability that i couldn't able to understand u properly. So, it's absolutely no need to be sorry at all.

Any way , best of luck & all the best for u'r future progress...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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