[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1399618562"][quote author="riwakawd" date="1399594339"]
I want to be able to do it via server side can do it with input highlighted 'has-error' but the only issue I am having, is if input is filled in correct should be highlighted 'has-success'.
Currently when use this <?php echo (validation_errors() != '')? 'has-error':'has-success'; ?> makes the input always highlighted 'has-success' when no error.
if there was away to addClass and removeClass using that would be good. Working like the javascript but using codeigniter validation.[/quote]
That is correct!
So let's see... You only want the success or fail class to be "inserted" After the form has been posted/submitted?
So where does that happen? And that is where you would set your class values...
As another hint... you'd could have...
In your Form View
Code:
<div<?php echo $div_name_class;?>> Stuff here </div>
Then in your Controller - check to see.
1. If the Form is submitted AND it's a success
Code:
$form['div_name_class'] = ' class="my-success-class"';
2. if the Form is submitted AND it's a fail...
Code:
$form['div_name_class'] = ' class="you-muffed-it-fella-class"';
3. The Form is NOT Submitted
Code:
$form['div_name_class'] = '';
Of course you can do more clever things in achieving that, but that's the basics!
Cheers
Tim
[/quote]
Hi my checked box not validating errors not showing up on the view page? Should do but not same as the codeigniter user guide
Code:
<div class="panel panel-default">
<div class="panel-body">
<?php echo form_open('install/stage_1/index');?>
<?php echo validation_errors('<p class="error">', '</p>'); ?>
<div class="form-group">
<div class="terms" scroll; height: 550px;"><?php echo $text_terms; ?></div>
</div>
<div class="form-group">
<?php
$data = array(
'name' => 'terms',
'id' => 'terms',
'value' => '1',
'checked' => FALSE,
'style' => 'margin-right: 10px;'
);
echo form_checkbox($data);
$data = array(
'value' => $button_continue,
'role' => 'button',
'type' => 'submit',
'class' => 'btn btn-primary'
);
echo form_submit($data);
?>
</div>
<div class="form-group">
</div>
<?php echo form_close();?>
</div>
</div>
Controller
Code:
public function index() {
$data = array();
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('terms', 'Agree to License', 'required');
if ($this->form_validation->run() == FALSE) {
$data = array();
$data['heading_step_1'] = $this->lang->line('heading_step_1');
$data['heading_step_1_small'] = $this->lang->line('heading_step_1_small');
$data['text_license'] = $this->lang->line('text_license');
$data['text_installation'] = $this->lang->line('text_installation');
$data['text_configuration'] = $this->lang->line('text_configuration');
$data['text_finished'] = $this->lang->line('text_finished');
$data['text_project'] = $this->lang->line('text_project');
$data['text_documentation'] = $this->lang->line('text_documentation');
$data['text_footer'] = $this->lang->line('text_footer');
$data['text_support'] = $this->lang->line('text_support');
$data['button_continue'] = $this->lang->line('button_continue');
$data['text_terms'] = $this->lang->line('text_terms');
$this->load->view('template/stage_1', $data);
} else {
redirect('install/stage_2');
}
}