Skip Navigation

[Resolved] Value not save to database if select field is disable or remarked

This support ticket is created 3 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2152855

Dear Sir/Madam,

I have a link to create child post with parameter passing

<a href="/add-new-contestant/?parent_vwcm-application_id=[wpv-post-id]&mode-type=[types field='type' output='raw'][/types]"><span class="badge badge-success">Create Child Post</span></a>

From the child add new form, I have a custom select field which will accept the parameter mode-type

[cred_field field='contestant-mode' force_type='field' class='form-control' output='bootstrap' value='[wpv-search-term param="mode-type"]']

I tried two jQuery script to disable the field not to be changed

jQuery("select[name='wpcf-contestant-mode']").prop('disabled',true);

or

jQuery("select[name='wpcf-contestant-mode']").attr('disabled', 'disabled');

or remark the field

<!--
[cred_field field='contestant-mode' force_type='field' class='form-control' output='bootstrap' value='[wpv-search-term param="mode-type"]']
-->

After I saved the form, only the field wpcf-contestant-mode doesn't save data to the database, may I know how I can disallow user to change the value?

#2153667

Hello and thank you for contacting Toolset support.

Do not use the last option as it will completely remove the field from the form. So, when submitted, the form will not have a value for the field.

<!--
[cred_field field='contestant-mode' force_type='field' class='form-control' output='bootstrap' value='[wpv-search-term param="mode-type"]']
-->

Instead, try to make the field read only with the following Javascript code:

jQuery("select[name='wpcf-contestant-mode']").attr('readonly', 'true');

I hope this helps. Let me know what you will get, and if you have any further questions.