⚠ In case you've missed it we are migrating 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 forum is read-only and soon will be archived. ⚠


Member Since 08 Dec 2012
Offline Last Active Jun 12 2013 03:47 AM

Topics I've Started

AJAX Listing View? Multiple Listing Views?

24 May 2013 - 10:08 PM

Has anyone ever sucessfully loaded the Grocery CRUD listing view via an AJAX request (.getJSON)? It seems that it would require a lot of code refactoring. I'm currently using Datatables theme, but could switch to flexigrid if it would make it easier.


I noticed this question from the past.




It seems it's difficult to support AJAX functionality of the listing view. It would be a great enhancement. You could then load multiple listing on one HTML page. This would make subpanel listings a possibility.








Error when using both set_relation_n_n and set_relation to the same table.

08 May 2013 - 08:07 PM

Has anyone seen this error when trying to use both set_relation_n_n() and set_relation() to the same table?


I've got a 1-to-many and a many-to-many relationship to a 'contacts' table that I need to define. The many-to-many is for partners contacts and the 1-to-many is for a related vendor.


$crud->set_relation('vendor_id', 'contacts', '{contacts.first_name} {contacts.last_name} ({contacts.company})');

$crud->set_relation_n_n('contacts', 'collections_contacts', 'contacts', 'collection_id', 'contact_id', '{contacts.first_name} {contacts.last_name} ({contacts.company})', 'priority');


The column names seem to be prefixed with the table name and the "as" name. Note: j96b1f972.contacts.first_name


Error Number: 1054

Unknown column 'j96b1f972.contacts.first_name' in 'field list'

SELECT `collections`.*, CONCAT('', COALESCE(j96b1f972.contacts.first_name, ''), ' ', COALESCE(j96b1f972.contacts.last_name, ''), ' (', COALESCE(j96b1f972.contacts.company, ''), ')') as s96b1f972 FROM (`collections`) LEFT JOIN `contacts` as j96b1f972 ON `j96b1f972`.`id` = `collections`.`vendor_id`

I assume I could just create my own custom field dropdown for the "vendor_id" field as it's not as special as the many-to-many relationship. Any suggestions?


set_relation() - Edit from both sides of relationship?

27 April 2013 - 02:54 AM

Again, thank you for continuing to support this project through this forum!


I think I'm overlooking something simple. I'm trying to allow someone to edit from both sides of a 1-n relationship (set_relation). For example, the Grocery Crud demo of Employees has a relationship to the Office City. You can easily view a list of all employees, edit an employee and change the Office City from a drop down.


Demo: Employees - Office City





But, if you created a list view of Office Cities (or Offices), edit a Office City... there's no way to edit the related Employees to that Office City. What's the best way to create this multi-select drop down (chosen plugin) field? I assume I would need to write my one model after save callback to save the relationship data properly.


n-n relationship?


I noticed that the n-n relationship allows you to edit from both sides of the relationship; as expected. Should I setup a related table and just use a n-n relationship instead? It's not really a n-n, as an Employee can only belong to one Office City (at least in my issue). Not using the proper relationship bothers me a bit. How can I then prevent an Employee from being added to Multiple Cities? Custom add/edit Validation rules?


Am I missing something?

Thanks, Jeff


What's the best way to create a custom Add or Edit view?

08 December 2012 - 07:23 PM

I've been working with Grocery Crud for over a month now and I've found it extremely helpful. Most everything I've needed to modify has had a callback; with the great API documentation. Great work!

I've come across a situation where I need to create more customized Add and Edit views. I realize that one approach, would be to simply duplicate the entire theme folder with views, js, css, etc. But this seems a bit extreme. All I really want to override is the add.php view, located at /assets/grocery_crud/themes/datatables/views/add.php.

I noticed the add view is hardcoded in the grocery_crud.php library.

protected function showAddForm()


What's the best approach to this problem?

Thank you,
Jeff Walters