0

I am learning Joomla! and I am building my first component.
My problem is now that I have a form that needs to store data in the db.
All is working right up until that point. The table that my form is using is not getting any values. So all that is ever saved is NULL values.

How do I get the values from the form fields into my table?

I am using Joomla 3.2

This is the error I keep getting

Save failed with the following error: SQL=INSERT INTO `test_redbiz_note` () VALUES ()

code:

controller

table

form

model

Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
Jim
  • 995
  • 2
  • 11
  • 28
  • yea I guess that is important :) I edited the question. – Jim Dec 10 '13 at 13:11
  • `JRequest` is deprecated, please have a look at this: http://docs.joomla.org/Retrieving_request_data_using_JInput – Lodder Dec 10 '13 at 13:13
  • 1
    I'm not sure why you are doing anything beyond giving the prefix and the database table name in your constructor, JTable will already create properties for each column in the database that match the column names and $table->load($pk) will load your row. – Elin Dec 10 '13 at 13:35
  • So I sould remove the public vars in the table class and not overwrite the save function in the controller? – Jim Dec 10 '13 at 13:43
  • Well you should only overwrite if you need to for some reason .. I just don't see that you're doing anything special there but maybe I'm missing it. – Elin Dec 10 '13 at 20:13
  • Okay, so now I am just letting joomla do the save and not really touch anything, but the problem is still the same, the table does not get any values from the form. – Jim Dec 11 '13 at 08:25

1 Answers1

0

So I found a solution.

I still cant get joomla to get the form values to the table so I have to do it myself by overwriting save() in my controller.

   public function save()
   {
        $table = $this->getModel()->getTable();
        $jinput = JFactory::getApplication()->input;
        $JinputFilteredData = $jinput->POST->get('jform','','array');
        $values = $JinputFilteredData["GroupOfFields"];
        $table->bind($values);
        $table->store();
        return;
    }

This does not seem to be the best solution though...

Jim
  • 995
  • 2
  • 11
  • 28