12-28-2015, 12:11 AM
(This post was last modified: 12-28-2015, 12:12 AM by wolfgang1983.)
(12-28-2015, 12:04 AM)Diederik Wrote: You could try the following to debug your problem:
PHP Code:<?php
class Forum extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('model_forum');
$this->load->library('form_validation');
}
public function index() {
$data['forum_user_total_votes'] = 'Your Rep ' . $this->model_forum->get_forum_user_reputation();
$data['total_votes'] = $this->model_forum->get_forum_question_reputation();
$this->load->view('common/header');
$this->load->view('forum/forum_question_demo', $data);
$this->load->view('common/footer');
}
public function down_vote() {
$this->form_validation->set_rules('down_vote', 'Down Vote');
if ($this->form_validation->run() == FALSE) {
echo "Does Not Work";
var_dump($_POST);
// This should give you details on why the form was rejected:
var_dump(validation_errors());
//redirect('forum');
} else {
echo $this->input->post('down_vote');
$this->model_forum->update_forum_question_down_vote();
$this->model_forum->update_forum_user_reputation_down_vote();
redirect('forum');
}
}
}
Thank you for tip in the set_rules for some reason to make it work requires a third part i.e required and then it worked. Unsure why need that third part to make it work?
Code:
$this->form_validation->set_rules('down_vote', 'Down Vote', 'trim|required');
Will not work if just have
Code:
$this->form_validation->set_rules('down_vote', 'Down Vote');
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!