⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

help me with Field function



kenshicu
  • profile picture
  • Member

Posted 25 March 2013 - 17:43 PM

in add/edit form I need to put a selectbox or textbox (field4), which does not exist in the database, so I put:

$crud->fields('field1','field2','field3','field4');

but to save the form, by clicking the button (Save and go back to list), the system does nothing, does not save, does not move. :(


victor
  • profile picture
  • Member

Posted 26 March 2013 - 09:28 AM

does the save button works?

victor
  • profile picture
  • Member

Posted 26 March 2013 - 09:37 AM

I think you should use callback functions for that. for example 'callback before insert'.
your code doesn't works because the field4 doesn't exist in your table.
you need use your extra data before inserting and then delete it.

kenshicu
  • profile picture
  • Member

Posted 26 March 2013 - 12:48 PM

the Save button does not work when I add the field4. I guess the error is to try to save the field4 in the table, where it does not exist.

Perhaps using a 'callback before insert' work, if I remove the field4 of $post_array, but I do not know if this can be done.


victor
  • profile picture
  • Member

Posted 26 March 2013 - 13:19 PM

can you explain what you need in more details?

kenshicu
  • profile picture
  • Member

Posted 26 March 2013 - 14:10 PM

I need to use a field4 in add/edit form to use as parent selectbox using 'Dependent dropdown' and that I have it, but it will not let me save, because guess who attempts to keep the field4 in the database.
I think the solution is in a 'callback before insert' it processes the array $post_array, what I want is to remove the field4 of $post_array with something like this:

 

function _test_callback_before_insert($post_array) {
unset($post_array['field4']);
  return $post_array;
}

but it does not work.

as knowing the content of $post_array?


kenshicu
  • profile picture
  • Member

Posted 28 March 2013 - 21:17 PM

any idea with this?