• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hidden field not been submitted with form validation

#1
I have a small issue.

I am now using form helper and form validation to submit my up and down votes.

But for some reason using the form validation on the down_vote does not submit it keeps on returning false.

I am not sure why form validation does not work with hidden fields.

The var dump is working. form helper is auto loaded.


Code:
array (size=1)
 'down_vote' => string '1' (length=1)


Controller Forum

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);

            
//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');
        }
    }

View

PHP Code:
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 text-center">
<
div class="well">

<?
php echo form_open_multipart('forum/up_vote');?>
<?php 
echo form_hidden('up_vote''1');?>
<button type="submit" style="background-color: transparent; border: none;"><i class="fa fa-angle-up fa-4x"></i></button>
<?php echo form_close();?>

<div class="total"><?php echo $total_votes;?></div>

<?php echo form_open_multipart('forum/down_vote');?>
<?php 
echo form_hidden('down_vote''1');?>
<button type="submit" style="background-color: transparent; border: none;"><i  class="fa fa-angle-down fa-4x"></i></button>
<?php echo form_close();?>

</div>
</div> 
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Hidden field not been submitted with form validation - by wolfgang1983 - 12-27-2015, 11:48 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.