Welcome Guest, Not a member yet? Register   Sign In
form validation error
#1

[eluser]Blaskunk[/eluser]
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:
for($i=1;$i<$num_dest;$i++)
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:
$this->validation->field_error;

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

[eluser]mi6crazyheart[/eluser]
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...
#3

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

[eluser]pickupman[/eluser]
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:
Code:
&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.
#5

[eluser]Blaskunk[/eluser]
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 :
$config=array(
array('field'=>'field'.$i,
'label'=>'my label',
'rules'=>'required'),
array(...

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...
#6

[eluser]mi6crazyheart[/eluser]
@Blaskunk
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...




Theme © iAndrew 2016 - Forum software by © MyBB