Home › Toolset Professional Support › [Resolved] Unable to render dynamic field on site
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 10 replies, has 2 voices.
Last updated by Minesh 1 year, 1 month ago.
Assisted by: Minesh.
On a CRED form, I am trying to show a dynamic field value that users can select from.
The for shows up but the field is not visible anymore.
Form code related to the field --
<div class="form-group"> <label for="%%FORM_ID%%_generic-company-id">[cred_i18n name='generic-company-id-label']Select Your Employer[/cred_i18n]</label> [cred_generic_field type='select' field='generic-company-id'] { "required":1, "options":[ [xyz-ics snippet="Company-id-json"] ] } [/cred_generic_field] </div> [cred_field field='form_submit' output='bootstrap' value='Claim Profile' class='btn btn-primary btn-lg']
Front end view - link 1 -- hidden link
Front-end error - Link 2 -- hidden link
How form looks in setup (it shows the value from the field) - Link 3 - hidden link
What am I missing? Is there a limit on how many value can be in the JSON?
Hello. Thank you for contacting the Toolset support.
I'll have to make sure that the json string return the options for the select dropdown should return only options.
Can you please share problem URL and admin access details and tell me where you added the JSON code.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
You can integrate the chosen select.
I've added the related chosen CSS and JS at top of your form:
- hidden link
And to your form's JS editor I've added the following custom JS code:
jQuery(document).ready(function($){ $(".chosen-select").chosen({ no_results_text: "No items found!", max_selected_options: 1 }); });
Please check the following reference ticket:
- https://toolset.com/forums/topic/limit-number-of-options-visible-in-search-dropdown-box-taxonomy-scroll-list/#post-1136059
Can you please confirm it works as expected: hidden link
Minesh,
The solution works well for Select2. Thanks a lot. 🙂
But the original problem is still there. If I have more than 800 records on the dropdown, he select2 field is also not available.
You can look at the shortcode link I shared in the private chat. Is there a cap on number of records you can render in the shortcode on a select2/select field?
Loading more than 800 options is too much. I'm not sure exactly what would cause this until I will setup the site on my local server.
Maybe you should try to increate memory limit on your server or increase other server resources. Does that helps?
I don't want to load more than 800. I just them to have an option to search for all of them.
Is there way this can be done?
It's custom script and I do not have much idea about how much load (options) it can have. You will have to try and test on your own.
That's fine. My question is -- is there a restriction on Toolset how many elements can exist in a JSON?
I ask this because if Toolset has a limitation than any increase in memory on my end won't make a difference.
That's fine. My question is -- is there a restriction on Toolset how many elements can exist in a JSON?
==>
I dont think there is such restriction added by Toolset. And its generic select field so there should not be any restriction.
I think this is a problem with Toolset and not with my code.
Here is why
I was able to render the output of the shortcode on the front-end with the right JSON format without any limit.
The problem is in the generic select field that is not rendering the value beyond 800. So this is not a backend issue. This seems like a front-end issue where the following code is not able to render the select field on the front-end.
<label for="%%FORM_ID%%_generic-company-id">[cred_i18n name='generic-company-id-label']Select Your Employer[/cred_i18n]</label> [cred_generic_field type='select' field='generic-company-id' class='chosen-select'] { "required":1, "options":[ [xyz-ics snippet="Company-id-json"] ] } [/cred_generic_field] </div>
I think this falls under Toolset's area of expertise and I would like to know if there is a workaround.
Here is a sandbox auto-login link:
- hidden link
I've created the "Code snippet" namely "toolset-json-generator" that is generating 1500 JSON options.
add_shortcode('get_json_options','func_dynamic_json'); function func_dynamic_json(){ $company_posts_array = array(); for($i=1;$i<1501;$i++){ $string = '{"value":' . '"' . $i . '",' . '"label":' . '"First American ' .$i. '"}'; $company_posts_array[] = $string; } if(!empty($company_posts_array)) { return implode(",",$company_posts_array); } }
I've added the generic select field to the following form - you can see at top of the form:
=> hidden link
[cred_generic_field type='select' field='test-json-field'] { "required":0, "default":[], "options":[ [get_json_options] ] } [/cred_generic_field]
I can see on the frontend at top of the form it does display the select box with 1500 options without any issues:
=> hidden link
As far as I can see this is not related to Toolset as I can easily display 1500 options with the generic select box.
Am I missing anything here?