Jump to content

form validation in code igniter


gibbo1715

Recommended Posts

All

 

I was introduced via this forum to a fantastic framework called codeigniter which im assuming a number of you are familiar with

 

I have got everything i want working except for the validation aspect where i need a little help and i ll try and explain how i ve got things set up as best i can

 

I have been playing using arrays to populate my form view data as follows

 

//Set up the table components as I want them viewed here

$data['ftitle']		= array('name'=>'title',
                            'size'=>30
				  );
$data['fauthor']	= array('name'=>'author',
                            'size'=>30
				  );
$data['fpublisher']	= array('name'=>'publisher',
                            'size'=>30
				  );
$data['favailable']	= array('name'=>'available',
                            'value'=>'yes',
						'checked'=>TRUE
				  );
$data['fsummary']	= array('name'=>'summary',
                            'rows'=>5,
						'cols'=>60
				  );	

				  

//end books *******************************************					  
return $data;	

 

 

In in my view page i call this as follows

 

<th><? echo $publisher ?> </th>	
<!--Validation from my form_validation.php file in the config folder-->
<th><? echo form_input($fpublisher).br(); ?> 
<?php echo form_error('publisher'); ?>
</th>					

and so on.....

 

This all works fine and i can get the form validation working as well but i cant figure out how to not loose my data when the validation fails

 

im aware of the set_value() function but not sure how i would use that as part of my form_input command?

 

Can anyone assist or do i need to go a totally different route

 

thanks

 

gibbo

 

P.S. hope that makes sense if not i ll try and explain a little better

 

 

Link to comment
Share on other sites

It's quite simply really, you just set it in the array.

 

For example:

 

$data['ftitle']      = array('name'=>'title',
                            'size' => 30,
                           'value' => set_value('title')
                 );
$data['fauthor']   = array('name'=>'author',
                            'size' => 30,
                            'value' => set_value('author')
                 );

 

And so on...  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.