Sonata admin dropdown with ajax data results - php

I am working on a sonata admin panel using symfony 3.3. I have two entities Category and Chalets. They are associated many to many so that One category have many Chalets and Chalet can be associated to many Categories.
I want the functionality in my admin panel to show the Chalets based on Category choosen from dropdown and a button to replicate the same to add another category with Chalets and so on.
The picture below will give you the deep insights.
Picture of my current functionality
Right now all the Chalets added in the database are visible in the dropdown I want to show only the selected category Chalets to be shown. Alson, the button(Add more) will replicate the Category and Chalet to repeat the process.
Thanks!

What you need is sonata_type_collection field.
It will look a bit different out of the box, but capabilities is exactly what you want.
So, how it works:
sonata_type_collection field will include a table inside of your edit form. Every row in this table is another Category.
there is possibility to add "Add" and "Delete" buttons, so you could add and delete categories directly from this edit form.
second column in this embed table could be "Charlets" field, and it can be editable inline (select2 elements). So you can choose charlets for every category.
when you add Category - it's a "create" form, it has only Category dropdown. But when you edit a row inline - it's an "edit" form, it will has also "Charlets" multi select. And options for this multi select can be generated based on chosen Category.
So, all this will work without any custom templates/Ajax calls.
P S. If you still want to customize UI - easier to do it with JavaScript.

Related

Dynamically pass a Product ID as the main Product Field on a Gravity Form (Product Add On)

I've got a great form set up to allow the building of a complex product and then add it to the cart (using the GForms Product Add on). All lif this is perfect on the actual Woocommerce product page.
What I'd love to do is have this form embedded on a page and populate the Product ID dynamically, so that the form still picks up the product details and will add the new Item to the cart just as it does on a shop page. Having it on its own page (or on any page of the site) will allow us to offer a larger, focused experience to select all the options.
I've been looking into the code and the docs but I can't seem to make it work. The code references product_id everywhere, but the dynamic field option is name. So is this possible? Thanks!
If the data you are attempting to map is simple then the following snippet plus Gravity Forms default {embed_post} and {custom_field} merge tags can get you there:
https://gravitywiz.com/dynamic-products-via-post-meta/
If your data is more advanced (like mapping product attributes), check out Gravity Form Populate Anything:
https://gravitywiz.com/documentation/gravity-forms-populate-anything/

bootstrap how to add/remove category just like opencart?

Recently, I working on a PHP project that comes with product and product category. Each product can assign to multiple categories.
Product name, quantity all these are quite easy to handle as they are input text box. But for category, its a bit complicated. So i use checkboxes to handle category selection. It works fine for inserting mysql as i simply use foreach loop to check which checkbox has clicked. To update/del by using array_diff to check the new selected checkbox or unselected.
Then I found out that opencart handle category in this way
1 input box for user to key in category name with auto suggestion, when clicking on the suggested name, it will be added. so to remove it, just click on the minus sign button. Its simply and straight forward.
So I am wondering is there a way to do something like that by using bootstrap design? OR is there some opensource for such function ?

How to add custom field into product in opencart 2.0

My question may be duplicate but read carefully before voting down, as my problem is different.
I am developing a public module for opencart in which i want to add some attributes for all products. Attribute will be same for all type of products for all categories. Attribute may be select box, check box, text.
For example
1) Length - text box
2) Category - select box
As i want these in my module so don't want to modify core files, so is there any option available or how i can override product edit form to add more custom fields.
If i understand your question correct, you want "Attributes" for all products for all categories and don't want to override core files.
Then you can do it using 2 ways without overriding core files
1st - add attributes and groups form Opencart default then using that module, connect those attributes to products.
Every thing is game of entry in database table like when admin edit any product and want to add product attribute then what will he do, he will go to attribute tab and then select attributes and then save product means save attribute entry to database for that product that it, so you need to add those entries using your module for products.
2nd way - I will add attribute groups and attribute create entry in my module (if you want every thing in your module) and other part will be same like 1st way.
So next time when you edit any product then you will see these attributes selected in your product already.
Note
- admin can add attributes value form module or have to edit product for that, you have to manage that.
- how you manage duplicate entries for same attributes for product, you have to check that in your code

Create a custom attribute and add it to category grid view Magento

On some of my products (not all) I need to add a drop down to select from a list of products (varying depending on product). What is the best way to implement this so it get be chosen next to "add to cart" on the category grid on front end?
I did this just before few days. You want to show dropdown of simple products for any configurable products in category page, right? Check below link it will explain you step-by-step on implementing it. Let me know if you have something different in mind.
http://www.catgento.com/adding-configurable-product-options-to-category-list-in-magento/

How to filter dropdown data in SocialEngine sign up form?

I am working with Social Engine which is based on Zend Framework and Smarty Templates.
I have created two custom drop down fields "Country" and "City" in sign up form using SocailEngine admin panel.
I want to know, is there any way to filter the data in City dropdown based on selected Country?
I know how to implement this feature using simple AJAX and PHP, but I want to know how to do this using SocialEngine admin panel and what is the best way to do this in a ScocialEngine based application.
Thanks
I have found the way to do this, here are the details:
In admin panel, click 'Profile Fields' in Global Settings sections.
Add a new field Country in fields tree.
There is a "Field Type", change it from Text Field to Pull down Select Box.
Scroll down to Options section, click 'Add New Option' link.
Add country name in Label field. In dependency box, choose Yes and type 'City' in Dependent Field Label box.
Repeat step 5 for all countries you want to add in your signup form.
Click Edit Field button to save changes.
In fields tree, you will see a sub tree under Country field. All countries will be visible in this tree with Dependent Field link.
Click Dependent Field link against a country and make it a drop down and populate it with cities in that specific country.
Repeat Step 9 for all countries.
It will take time but it is a one time effort and you will get what you need without modifying the code.

Categories