Welcome Guest, Not a member yet? Register   Sign In
Posting a form to DB when form contains ’form_textarea’
#1

[eluser]Energetic Pixels[/eluser]
Ok, I have the following form:
Code:
<?php echo form_open('Glossary/createTerm');
   $data_textarea = array(
    'name' => 'definition',
    'id' => 'definition',
    'cols' => '30',
    'rows' => '12'
    );
   echo form_label('Course Number', 'crseNumber');
   echo form_input('crseNumber', 'Course Number');
   echo form_label('Term', 'term');
   echo form_input('term', 'Term');
   echo form_label('Definition', 'definition');
   echo form_textarea($data_textarea);
   echo form_label('Realm', 'realm');
   echo form_input('realm', 'Realm');
   echo form_label('Module/Lesson', 'lesson-module');
   echo form_input('module-lesson', 'Module/Lesson');

   echo form_submit('submit', 'Submit');
  ?>  
  <?php echo form_close(); ?>
My control function looks like:
Code:
function createTerm() {
  $data = array(
   'crseNumber' => $this->input->post('crseNumber'),
   'term' => $this->input->post('term'),
   'definition' => $this->textarea->post('definition'),
   'realm' => $this->input->post('realm'),
   'lesson-module' => $this->input->post('lesson-module')
   );
  $this->gloss_model->create_term($data);
  $this->index();
}

But when I run it, I get a undefined property pointing to the 'textarea' within the createTerm function. When I change that specific line to be '$this->input->post..' it works. By using the 'input' method, is the correct way??

respectfully,
Anthony
#2

[eluser]jmadsen[/eluser]
hi E-P,

This area is for "General CodeIgniter Discussion (no code)"

Please post in the Code area for a response.

thank you
#3

[eluser]Robin Sowell[/eluser]
Wink I shifted it over for you.

And yes, unless you've got something going on we can't see, $this->textarea isn't defined. What [url="http://ellislab.com/codeigniter/user-guide/libraries/input.html"]$this->input->post('x')[/url] will do is simply return $_POST['x'] or FALSE if undefined. More or less. Since it looks like you named your textarea field 'definition', then $this->input->post('definition') should give you what you want (i.e., $_POST['definition'], only better).




Theme © iAndrew 2016 - Forum software by © MyBB