CodeIgniter Forums
hidden field value not posting when saving to the db - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: hidden field value not posting when saving to the db (/thread-47597.html)



hidden field value not posting when saving to the db - El Forum - 12-14-2011

[eluser]allancaps[/eluser]
Hi, any ideas why my code isn't posting the hidden field's value when saving to the database?
here's my Model:
Code:
$new_article_insert_data = array(
        'article_title' => $this->input->post('article_title'),
        'article_slug' => $this->input->post('article_slug'),
        'article_category_id' => $this->input->post('article_category_id'),
        'article_subcategory_id' => $this->input->post('article_subcategory_id'),
        'article_content' => $this->input->post('article_content'),
        'article_keywords' => $this->input->post('article_keywords'),
        'article_postdate' => mdate($datestring,$time),
        'user_id' => $this->session->userdata('user_id')
      );
      $insert = $this->db->insert('articles', $new_article_insert_data);

and my View:
Code:
<?php echo form_open('article/submit_article'); ?>
<fieldset>
   <legend>Article Information</legend>
   &lt;?php
     $article_title = array(
    'name' => 'article_title',
    'id' => 'article_title',
    'onKeyup' => 'generate_slug();'
   );
     echo form_input($article_title, set_value('article_title', 'Article Title'));
  
   $slug_field = array(
    'name' => 'article_slug',
    'id' => 'article_slug',
    'disabled' => 'disabled'
   );
   echo form_input($slug_field);

   echo form_dropdown('article_category_id', $category_list);
  
   $subcategory = array(
    '1' => 'Automobiles',
    '2' => 'Food and Drinks',
    '3' => 'Gadgets',
    '4' => 'Health and Beauty',
    '5' => 'Music',
    '6' => 'Videos',
    '7' => 'Others'
   );
   echo form_dropdown('article_subcategory_id', $subcategory, '2');
   echo form_input('article_keywords', set_value('article_keywords', 'Article Keywords'));
   ?&gt;
</fieldset>
<fieldset>
   <legend>Article Content</legend>
   &lt;?php
     echo form_textarea('article_content', set_value('article_content', ''));
     echo form_submit('submit', 'Submit Article');
   ?&gt;
   &lt;?php echo validation_errors('<p class="error">'); ?&gt;
</fieldset>
&lt;?php echo form_close(); ?&gt;

The thing is, the value of the article_slug input is generated by JavaScript. Is there anything that might cause the value to clear when submitting the form?

Thanks in advance!