Skip Navigation

[Resolved] Altering Custom Fields Slightly Without Creating A Whole New Custom Field

This support ticket is created 4 years, 7 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
- 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 6 replies, has 2 voices.

Last updated by michaelO-8 4 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1623579
job types 2.PNG
job types 1.PNG

Tell us what you are trying to do?

I have a custom type called "Job Types" which is a check box list with 4 options:
-Full-time
-Part-time
-Internship
-Remote

This type is used in a toolset form so companies can post information about their open positions.

However, some customers would prefer to have different options listed for example:
-Full-time
-Part-time
-Co-op
-Volunteer

For now, each time a customer requests a slightly different version of job types, I create a new custom field with the job types that they request and create a new form which has this new custom type in it so they can post this information.

However, it seems like this is not the best approach to have many different "job type" custom fields with slightly different options. Since the job type choices are usually similar, I was wondering if there was a way to keep the main custom type "job type" and alter the options shown by using different forms.

In Views, it seems like I can use the same custom type and manually designate options. In this case, it seems like even if the the custom type has four options (Full-time,Part-time,Internship, Remote), it seems like I can display different ones to the user by manually designating them. However, in toolset forms, I am not sure if this is possible as I am able to change the label of a custom type (Job Types), but it seems like I cannot edit the names of the check box choices within the form. Is it possible to do this? Any recommendations?

#1624185

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The thing is that, Types checkboxes field is saved in special formal called serialized array and that is why its hard to play with them to update it using PHP manually.

As you want different options for different forms, have you checked the Toolset form's Generic field? You can add any kind of field type like (textbox, checkbox, checkboxes, select) using the Toolset form generic field.
=> https://toolset.com/documentation/user-guides/front-end-forms/inserting-generic-fields-into-forms/

For example:

[cred_generic_field type='checkboxes' field='wpcf-job-type-full']
      {
      "default":[],
       "persist":1,
      "options":[{"value":"111","label":"Job Type 1"},{"value":"222","label":"Job Type 2"},{"value":"333","label":"Job Type 3"},]
      }
      [/cred_generic_field]

With the atrribute "persist":1, - the value will be saved automatically to the database.

Can you please check if this helps. You can adjust the options as per your requirement.

#1624391

Hi Minesh,

This sounds promising! Generic fields definitely sound like I can use different ones for different forms without having to make new customs types all the time.

I need to be able to display this data collected on the post created and in views, is this possible even with generic fields collected or only possible with custom post types? What is the benefit of custom post types vs generic fields?

#1625749

Minesh
Supporter

Languages: English (English )

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

I need to be able to display this data collected on the post created and in views, is this possible even with generic fields collected or only possible with custom post types?

What is the benefit of custom post types vs generic fields?
==>
Generic fields will be helpful when you want to add additional fields with your form which is not actually part of your custom field. For example, just think of Are you agree? policy checkbox field which should be required when you submit the form. This field do not need to save it but you will require to validate the form.

Your case is bit complicated as you are using the checkboxes field which is saved as a serialized array. Please note that, the additional option you will add to your checkbox field will not be available in the backend. In the backend you can only see the checkboxes options which you add. So you need to think how you want to manage this.

#1626049

I see, so it sounds like the way I am currently managing this is the only way? I will need to display the information in views, so it does not sound like Generic fields are an option.

#1628797

Minesh
Supporter

Languages: English (English )

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

Yes - thats correct.

Because as I admit in my previous reply, if you add additional options using generic field, that additional option will not show-up as option when you edit/add the post from the backend.

#1630809

Thank you for your help!