Skip Navigation

[Resuelto] Checkbox Values not Carrying Over

This support ticket is created hace 6 años, 9 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 13 respuestas, has 4 mensajes.

Last updated by Sean hace 6 años, 8 meses.

Assisted by: Shane.

Autor
Mensajes
#553686

I'm experiencing the exact same problem I did a year and a half ago:

https://toolset.com/forums/topic/setting-checkbox-values-in-cred/

I'm trying to populate a cred form with existing values from user form. Everything works except the checkboxes. They won't carry over, no matter what variation of the format I try.

[cred_field field='computer-experiencex' post='application' value='[types usermeta='computer-experience-3' user_current='true' output='raw'][/types]' urlparam='' output='bootstrap' readonly='true']

The field merely shows up with both checkboxes unchecked (and certainly not readonly). Suggestions? I've already tried recreating both sides (user field and post field) of the form. I'm also using the latest beta of cred (altho this has been a problem for more than a year).

#553772

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - as you are dealing with the checkboxes field you need to choose another approach to make checkbox checked but I need to check first on your install.

Could you please share problem URL and access details with information which checkboxes field to deal with.

*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#554044

The cred form also doesn't appear to carry over attachments either.

#554690

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I can see that you are using checkboxes field and checkboxes fields are special fields which is used to store serialize array. Also, the field on user profile checkboxes have value 1 and on CRED application form it's having the different value.

So, first of all, I have a question that I see computer experience field 3 times on user profile and 3 times on job application edit page in admin but on frontend CRED form which checkboxes field we need to relate with user profile checkboxes.

The better solution would be I suggest to change checkboxes field to custom taxonomy and save taxonomy term value based on the checkboxes selected in the user profile.

#554897

I have three versions of that field because of testing. Nothing more.

Changing the post field to a taxonomy hasn't solved the problem. The taxonomy has to be hierarchical in order to be shown as a checkbox (which doesn't make a lot of sense to me). I use this code:

<div class="form-group">
		<label>Computer Experience</label>
  	[cred_field field='computer-skill' display='checkbox' value='[types usermeta='computer-experience' user_current='true' option='0' state='checked']mac[/types][types usermeta='computer-experience' user_current='true' option='0' state='unchecked'][/types][types usermeta='computer-experience' user_current='true' option='1' state='checked']windows[/types][types usermeta='computer-experience' user_current='true' option='1' state='unchecked'][/types]' output='bootstrap']
	</div>

but it doesn't work. Should I be using 1s and 0s instead of actual words?

Also, any insight on getting attachments carried over?

#555076

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - in your initial post you shared the old ticket which is based on the checkbox field and with this ticket you are dealing with the check boxes field.

As I stated in my previous reply - checkboxes fields are special fields and its stored as a serialized array. I suggest if not taxonomy than you should change your checkboxes field type to dropdown select box and then we can pass the value or set the selected value based on your profile selection.

Please note that you need to change both application and profile checkboxes to select field. Could you please first change checkboxes field to select to both applicaton and on your profile page and then I will try to help you further.

#555335

I appreciate the checkboxes save their information in a different manner than a single checkbox, but it's the mapping of two identical variable types that I'm looking for.

1) You say "if not taxonomy" but you don't elaborate on my previous question. You suggested I change from a checkbox post field to a taxonomy. I did. My question was about the formatting of the values. Has this approach been known to work?

2) I don't see a multi-select box as an option in cred. Also, that's a much worse user experience for people filling out a form. It's a very uncommon field type.

3) Can someone closer to my timezone be assigned this ticket? The 12 hour delay in responses isn't very convenient.

#555607

I am not sure in what timezone you are, but I will take care of this now.

If you require american timezone, please state so, I can assign this to Shane (he works in American Time Zones).

I need to sum up the issue as I am quite lost about what the problem is, what you want to achieve, and what the relation to the old issue is.

As far I see, you populate a CRED Field with Types ShortCodes, is it?
That is a bit, let's say, dangerous. It is not really a good choice, it can break, and not because of Toolset, but because of WordPress itself, as you surely know, they do not allow nesting ShortCodes and the only place that is possible is actually Views, not CRED or Types.
It works, because we add some magic to the parser on our own.

But let's see this issue in detail.

1. You have a ... Not sure, a single Line? Created with Types.
2. Then you have some other Fields (a checkboxes, plural?) and that should show it's saved value in the above Field?

Sorry, your website returns a "ERR_EMPTY_RESPONSE" when I want to login, hence, I cannot be sure.

Anyway, if above is what you have, that works

But what will not work, is populate a Checkboxes field with a ShortCode of another Checkboxes Field.
That cannot work, as the Fields are once in display, and once in edit mode, how could that work?

It is a different complex array.

Also, self closing ShortCodes cannot be used in nested CRED Fields of this kind, you will notice the Red highlighted syntax, illustrating there is a syntax error.

I am not sure what exactly the situation is, but to me it seems, not possible.

#555836

I am in the US, yes.

That's not quite the issue at hand.
I have a user field, a checkboxes field (this is how it relates to the old issue, which was the exact same thing but with a singular checkbox field). It's part of a user's resume/profile. I want that data to be available when they apply for a job (a custom post type called Application). So I create another checkboxes field on the Applications side. I want to put the values of that user's checkboxes field into the identical Applications checkboxes field. It works for all other field types (except, as previously mentioned, attachments as well).
Minesh suggested I use a custom taxonomy for Applications instead of a custom field. I created this, but then didn't get any guidance on how this was different or more helpful.

I was just able to log into my test site if you want to try again.

#555942

I will assign your Ticket to Shane, as I am in Asian Time.

Anyway:

I want to put the values of that user's check boxes field into the identical Applications check boxes field

This is not possible, due to the simple nature of those fields.
You will need Custom Code to achieve this if you want to have it exactly like that.

You will not be able to populate any Checkboxes Field with another Checkboxes Displaying ShortCode.

A Single Checkbox is different; it has one option only.

I suggest, to just display that Fields (User Field) above the actual CRED field that the user needs to populate.
This is the only way you can pass that information.
Then, the user can see (read) the information and populate the field accordingly.

Another approach is to use PHP on form submit, wrapped in a cred_save_data() hook.
But this kind of PHP is extremely complex, due to the nature of Checkboxes.
It is a for each in a for each, and then you only have the actual data.
Now you need to update it...
Anyway, if you want a glimpse of how that looks, see this snippet, where I go over each kind of field in types:
https://pastebin.com/wz6dQVBE

It also goes over Checkboxes, around line 23 and subsequent.

It does the opposite. It gets Post data and updates User data.
But well, that is the same as you want, you just need to invert the Field Slugs and get functions.

But we cannot assist such code, I am afraid.

Shane will not be of more help here, he has to follow the same Coding Policies.

But maybe he has a brighter Idea than I do, let him reply here soon!

#556258

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Sean,

I took a look at this as well.

Checkboxes as my colleagues mentioned functions differently.

Now the reason why its not checked or selected is because checkboxes and radio buttons don't function on a bases where you would pass a value to it and it knows that this option should be selected.

It works with a "checked" attribute so if the value is set the checkbox or radio won't be pre-selected .

As Beda mentioned there would need to be some code to check the boxes based on the values. One way you can use Javascript to check the boxes based on the value that is in each of these types fields.

Thanks,
Shane

#556270

Ok. Since I can't have the boxes checked, nor have the values translated (regardless of the interface), I found a workaround. I merely created a text field and inserted the human readable values into that instead. Not as elegant, but it works.

I don't imagine there is any hope for the attachment question either?
If not, I can move it away from the user profile. Although it was convenient that way.

#556287

Shane
Supporter

Languages: Inglés (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Sean,

When you're mentioning Attachments what are you refering to like upload fields ?

I would imagine this wouldnt carry over either since its also a special field type.

Thanks,
Shane

#556295

Yes, I did mean file uploads. I'll use the same method to work around this.
I created a URL field and populated it with the link to the attachment. Serves my purpose.

[cred_field field='document-link' post='application' value='[types usermeta='documents' user_current='true' separator=', '][/types]' urlparam='' readonly='true' class='form-control' output='bootstrap']

Thanks for the assistance.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.