I am using backpack CRUD in laravel 5.3
I have 3 models: product, country and region. And I am looking way to similar function as jquery onchange ajax call.
Product crud has select for county and region. If I selected country, region select should filtered by selected country.
I don't know find crud function for this or way to insert js to edit view for one controller.
I'm afraid there's no pre-built field that will help you. Possible solutions:
create a custom field type for this purpose, starting from select2 or select2_from_ajax, that watches the change event on the first field and filters the second;
include the same javascript in your public\vendor\backpack\crud\js\form.js;
I would recommend option (1), seems cleaner to me.
Hope it helps, cheers!
Related
I wanted to create a custom page having all categories listed with checkbox and on click of that products should get filtered. Can anybody suggest how to go about it?
Just as an idea:
We are using Multiple Select in Layered Navigation von Manadev. There you get a Category filter which you may use.
Otherwise you may have a look at a Collection Filter as described here.
It would be quite easy to get a select with all your categories with category_id as option. Then you built your request.
I need to make a new type of field, let's call it included_table. If in Model employees I have a field of type select2 from model Departments, in Departments, I want to have a field of type included_table which displays the table of the employees from that department, in the same way as the crud does.
Is there an easy way of doing this? Or what would be the best way to start?
Thank you.
I don't think there's an easy way to do it. You'd have to code it yourself. You can start from the table field type, put it won't get you very far.
That's because it's a lot more complicated that it looks at first glance. Keep in mind that Backpack create/update forms work with refresh; if you put a table inside one of them, the expected behaviour might be to only "save" the information when you click the final "save" button; but you probably can't do that for the nested entity, because you'd be saving it with AJAX. Plus, you need to build that entire AJAX functionality yourself, including validation. It's not at all more difficult than using plain old Laravel - it's exactly the same. But Backpack won't help very much in this regard.
That being said, you'd probably be better off just putting a button in the list view for each Department, to go edit its employees. That's a lot easier to do, if you follow the nested resources tutorial.
Hope it helps.
I am using SugarCRM 6.5. I have a Users subpanel from my custom module. When I click Select, I need to filter the list of users. The challenge is it will only filter when triggered from the custom module and should not from other module using the User popup.
Tried this solution How I can customize query in view.popup in SugarCRM but it doesn't work on my end.
I manage to filter from User.php, adding the query filter in create_new_list_query, however it affects other module (it filters when it should not). I cannot figure out how to add condition for the custom module specific. It seems like it does not know what module that triggers the User popup.
Any possible solutions?
Your answers will be highly appreciated. Thank you!
is it possible to have a onepage-form for editing or creating a entry and its related (1 to n) entrys?
For example: I have a customer model, every customer can have unlimited addresses. I could now have a CustomerCrudController and a AdressCrudController with the adress having select2-field for the customer, maybe having some kind of filter for the customer in the adress-list-view but it would be a more fluid working having the ability to change or add adresses in the customers-edit-view.
Thanks
Christin
There is currently no built-in way to do that right now in a Backpack CRUD create/edit form. It's planned, but will not be happening until the next version of Backpack, which might take as long as 3-6 months to launch.
What you could do is:
1) create your own custom field type, say "select_or_create_address";
2) start from the select2 field type and create your custom functionality:
the results should could be loaded with ajax;
a button next to the select could open a popup with the create address form, either:
a quick form you code yourself that inserts a new address in the db;
the AddressCrudController create form (but without the menu, sidebar, etc); for this you'd need to create another method in the AddressCrudController, base off CrudController::create() but loading a different view;
when the address successfully added, the id should be inserted in the select2 as a value;
My recommendation is to go with the quick form, it should be faster to develop and you wouldn't have to resort to solutions like iFrame popups.
Cheers!
I am looking for best practices on SYMFONY FORM handling to achieve the following standard page (surprisingly I haven't found anything similar existing yet on SO).
Here is a shema of what I want to achieve:
As you can see at the top there is a SYMFONY FORM to filter the results that should be displayed.
It displays a table and each tuple of the table should permit to open another SYMFONY FORM kind linked to the tuple.
I am in the process of learning SYMFONY FORM, so far, I can manage to create the top row FORM to set the filter that'll apply to the table display.
But I wonder if anyone has experience on the second part: Displaying the table that embed as well many forms of a similar kind -That seems a bit more complex. I read about TWIG.EXTENSION and FORM.COLLECTION, I'll investigate that. But if someone could save me to re-invent the wheel and lead me to some direct shortcut, I'd be really grateful.
No idea if it's the best practice, but one way to do it would be to create a new property for your entity being listed in this table, called $editionForm (without mapping it to the database) for example.
Then, either throught a custom loop or by listening to a doctrine (or any ORM you use) hydration event (or triggering such an event if you don't use any ORM), fill the property with the generated form, probably within a dedicated service.
Then, just use it in your template like this :
$entity->getEditionForm()->render()