validation fix

This commit is contained in:
Claude 2012-04-13 17:30:43 +02:00
parent d0eca54435
commit 01aac16403
2 changed files with 19 additions and 5 deletions

View File

@ -30,7 +30,7 @@ class Main extends CI_Controller
function _form_prep($lang = 'php', $title = '', $paste = '', $reply = false)
{
$this->load->model('languages');
$this->load->helper("form");
$this->load->helper('form');
$data['languages'] = $this->languages->get_languages();
$data['scripts'] = array(
'jquery.js',
@ -91,9 +91,22 @@ class Main extends CI_Controller
{
$this->load->model('pastes');
$this->load->library('form_validation');
$rules = array();
$rules[]['code'] = 'required';
$rules[]['lang'] = 'min_length[1]|required|callback__valid_lang';
//rules
$rules = array(
array(
'field' => 'code',
'label' => 'Your paste',
'rules' => 'required'
) ,
array(
'field' => 'lang',
'label' => 'Language',
'rules' => 'min_length[1]|required|callback__valid_lang'
) ,
);
//form validation
$this->form_validation->set_rules($rules);
$this->form_validation->set_message('min_length', 'The %s field can not be empty');
$this->form_validation->set_error_delimiters('<div class="message error"><div class="container">', '</div></div>');

View File

@ -8,7 +8,8 @@
});
</script>
<?php if(isset($this->validation->error_string)){ echo $this->validation->error_string; }?>
<?php echo validation_errors(); ?>
<div class="form_wrapper margin">
<form action="<?php echo base_url(); ?>" method="post">