Saving form data

edited May 2016 in Modules
Hi,

We're using the forms module and have configured the form action to post to a custom controller. The form data is used to perform some calculations. How do we then save the data to the From_entries table?

Is it possible to use the form module to save the data.

I quickly looked at writing my own function to save the data, but the form data doesn't seem to have the form name, remote_ip or is_spam parameters.

I would also need to save the additional calculated fields, which aren't part of the original form.

Regards

David

Comments

  • edited 7:46AM
    I've also noticed that the 'text' field type value is set to 'text', and so displays a textarea. is there some config for this in the forms module?
  • edited 7:46AM
    You could do something like the following to save.
    $form = $this->fuel->forms->get('my_form'); $posted = $this->input->post(); $model = $this->fuel->forms->model('form_entries'); $entry = $model->create(); $entry->url = last_url(); $entry->post = json_encode($posted); $entry->form_name = $this->name; $entry->remote_ip = $_SERVER['REMOTE_ADDR']; $entry->is_spam = ($form->is_spam($posted)) ? 'yes' : 'no'; $entry->save();
    Regarding a text field type, you can specify an empty "type" value and it will be the default text box. The reason why it is a textarea is because it is assuming "text" is coming from the database field type.
Sign In or Register to comment.