Skip to content

Many-to-many relationship

To achieve a CRUD m-2-m table with an autocomplete dropdown by doing 2 things:

  1. making the sql parameter in the new C_DataGrid() call more complex (adding 2 left joins, similar to a  SO answer https://stackoverflow.com/a/17774479/2953987)

  2. adding a custom edit script via enable_edit(), which "deparses" the incoming edited values, saves the m-2-m values accordingly, and just include() the non-custom edit.php with the non-m-2-m values

With this architecture, phpGrid doesn't really know about the existence of m-2-m relationship and you will get all the usual phpGrid heavy lifting for free!

Thanks to Willi @sensape for his awesome work!



Feedback and Knowledge Base