Jump to content


help me with Field function

field function callback add edit selectbox button database

  • Please log in to reply
6 replies to this topic

#1 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 25 March 2013 - 05: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. :(



#2 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 26 March 2013 - 09:28 AM

does the save button works?

#3 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

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.

#4 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

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.



#5 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 26 March 2013 - 01:19 PM

can you explain what you need in more details?

#6 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 26 March 2013 - 02: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?



#7 kenshicu

kenshicu

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationHolguín, Cuba

Posted 28 March 2013 - 09:17 PM

any idea with this?







Also tagged with one or more of these keywords: field, function, callback, add, edit, selectbox, button, database

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users