-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the actual value of multiple_checkbox field type #40
Comments
Hi, you can determine what each |
Hi, I try to do in the way you recommend but I am facing this issue now. Since externally can change the number of the checkboxes in the multiple_checkbox some items can change from checked to unchecked. This is a capture: https://www.dropbox.com/sh/9ti0dhb8wtpawej/AAAv_XsuhYBb_a7Vj5op2zNFa?dl=0 |
Ah, I see. Let me get back to you. I'm going to look into how we're currently dealing with category selection fields. |
Hi, @xxtesaxx I ran into the same issue and had to create my custom field too. But my custom field also is not fully supported within the VB. I know there is a field type named categories that use the checkboxes in another way so hopefully, will be a solution for us. |
Yeah, a proper API to create new controls would be awesome! :) |
So, we're currently using the field type 'include_categories' => array(
'label' => esc_html__( 'Include Categories', 'et_builder' ),
'type' => 'categories',
'renderer_options' => array(
'use_terms' => true,
'term_name' => 'product_cat', // This is actually the taxonomy slug
),
'description' => esc_html__( 'Choose which categories you would like to include.', 'et_builder' ),
'toggle_slug' => 'main_content',
), |
I'm sure charles890123 already knows that and how to use it but that only works for terms of taxonomies :) Imagine for example you want to let the user select post types or maybe some other value which the user can define somewhere in the backend. Once a new value is added, it might mess with the selection. For example you have the post types "Artworks" and "Paintings" and now you add "Books". "on|on" becomes "on|on|" but instead of Artworks and Paintings, you now have Artworks and Books selected. That is why we would need a way to let the multiple checkboxes field (or another new control) return an array or comma separated list of slugs. Somthing like this:
or this:
And the return value would be one of those:
Now when a new value is added, no matter where in the options list, it would still return those values which were previously selected - which also brings backwards compatibility when updating our own modules. Because even if my option list is not dynamic, I might want to add new values in the future and maybe I want to provide the user a good usability by sorting the options by their localized labels. |
Yeah, I agree that would make much more sense than how it works today. We're going to replace it with a more robust solution soon. Most likely at the same time we launch support for custom fields in the VB. |
Good Day @lots0logs Any updates with this. |
Any updates? |
Did you gave up on us? |
No news on this, sorry! It has gotten pushed back due to other priorities. It's still planned though. |
Any time frame? |
No, I'm afraid not at this time. Sorry! |
Any good news on this? :D |
Hate to bump an old thread but any updates on this? |
Just today I saw that apparently we now can create our own custom fields by providing a react component. You can now easily implement your own multi-select. You could for example use select2 or simply use buttons and also style them however you desire. |
@xxtesaxx yeah, i was advised to go that route as well. |
Hi. Do you know any link about this, please? |
Simply create a new divi extension with npx create-divi-extension and check the sample in includes/fields. It's just another react component but I believe the value is stored as plain text so what I usually do is store more complex values as stringified json |
I also recommend to console.log or debug the field in render() to see all the props you have available. you can pass a lot of stuff via the field definition from php to jsx |
I could also use a better multi checkbox field 🙋🏻♂️ |
It is insane we don't have a proper way to handle dynamic lists in option fields, and we have to code our own react component for it. |
I know this thread is old, but there still doesn't seem to be a native solution for this and I couldn't find an example jsx component, so I wrote my own and posted it here: Divi Custom Field Type: Multi-checkboxes with IDs Hope it's of use to someone :) |
It is. I'll backport it to my plugin. Thanks a lot, bratan |
Hello.
Just a simple question. Can be a possibility to use a multiple_checkbox field type and get the actual values of the checked checkbox instead of a string like on||on|on|on|.
I am getting the values from a query and assign to the multiple_checkbox field on the options parameter. Is there any other field type that I can use for this purpose?
Thanks,
The text was updated successfully, but these errors were encountered: