1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Function to insert a record

Discussion in 'Community' started by marcelf, Jan 18, 2020.

  1. marcelf

    marcelf Member

    Level: Community
    Hi,

    I am developing a Form Plugin and need to insert another record in a list.

    Is there a function to pass the parameters and it creates the record correctly?

    I've seen the code below being used, but I must to create a complex record with dabasejoin, fileuploads ajax uploads, rating, and other elements, so I don't want to treat each element plugin.

    Any help will be apreciated.

    Thanks,
    Marcel

    Insert a record in another table and update a form's field with the records primary key(top)
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    $query->insert('tablename')->set('field = ' . $db->quote('bar'))
    ->set('field2 = ' . $db->quote('{tablename___elementname}'));
    $db->setQuery($query);
    $db->execute();
    $id = $db->insertid();
     
  2. lousyfool

    lousyfool Active Member

    Level: Community
  3. marcelf

    marcelf Member

    Level: Community
    But I would like to know if there is a function that can simplify the process of adding a record in a list.
    For example, I know that there is an updateFormData that allows you to update a record:

    http://fabrikar.com/forums/index.ph...ecord-from-external-script.39939/#post-200882
    $ formModel = JModel :: getInstance ('Form', 'FabrikFEModel');
    $ formModel-> setId (34);
    $ formModel-> updateFormData ("date_time", '2014-10-30 01: 43: 06', true);
    $ formModel-> updateFormData ("label", "test", true);

    Is there a function like CreateRecord or anything like that?
     
  4. lousyfool

    lousyfool Active Member

    Level: Community
  5. marcelf

    marcelf Member

    Level: Community
    Hi,

    I have been looking models/form.php and found:

    public function process
    and
    processToDB
    and also
    updateFormData

    This post is similar to my problem:
    http://fabrikar.com/forums/index.ph...ifferent-records-on-submit.41129/#post-207387
    $count = 0;
    foreach ($dates as $date) {
    if($count == 0) {
    $formModel->updateFormData('mpm_fabrik_deals___feature_date', $date[$count], true);
    $formModel->processToDB();
    $count++;
    continue;
    }

    I just want give the $formData to a function, and it create the record in a list with the given elements values.

    Anyone know if there is documentation about the main fabrik Classes, like FabrikFEModel and its functions?

    Thanks,
    Marcel
     

Share This Page