Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Filtering the left hand combo box for "has_many"

edited November 2017 in Modules
I need a has_many relationship between 2 tables, but the left hand (''foreign") list of the admin combo box really needs to be a filter, based on the id of the candidate table.

So if the foreign table were "schools", and the candidate "authorities" then the left list would be schools with an authority_id of the current authority admin view.

I think this is possible, perhaps with the has_many property definition specifying a method on the foreign table. A form_fields() derived custom field (type 'multi') would do the trick, but with extra post methods I guess.

If the former I'm not sure of the definition. Is is possible?

Comments

  • edited 4:02PM
    I'm not quite sure I totally understand but will give it a shot. It sounds like you want to customize the options on the left side to be something other then the default the has_many provides you which is the options_list method on the foreign model. The field the has_many generates is "multi" field which means it has an options property which the has_many relationship is automatically filling out. You can replace the options property with your own records in the form_fields method on your model.
  • edited 4:02PM
    Yes you got that right. I think I need to use the multi type definition in form_fields(), and test for edit mode, as the multi field filter won't be applicable until the record is saved. That also means an on_after routine to save the array.
  • edited 4:02PM
    I got exactly what I wanted with the multi field type - FuelCMS still has it!
Sign In or Register to comment.