Welcome Guest, Not a member yet? Register   Sign In
Return back values to view if any error in form fields
#6

Yes works fine.

Controller:
PHP Code:
// set data for test input field
$page_data['input_data'] = array(
 
  'value' => set_value('test_input'''),
 
  'class' => 'input_field',
 
  'name' => 'test_input',
);
// set some rule to trigger an error and repopulate the field
$this->form_validation->set_rules('test_input''Test Input''max_length[3]');
$this->form_validation->run(); 

View:
PHP Code:
<?php echo form_open(); ?>
   <?php echo form_input($input_data); ?>
   <?php echo form_error('test_input'); ?>
   <?php echo form_submit(array('value'=>'save')); ?>
<?php 
echo form_close(); ?>

Just make sure you have both the form helper loaded and the form_validation library loaded.

Best wishes,

Paul
Reply


Messages In This Thread
RE: Return back values to view if any error in form fields - by PaulD - 04-05-2017, 10:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB