Skip Navigation

[Resolved] Allowing 'cred_generic_field' to have multiple values

This support ticket is created 4 years, 10 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by MattI4840 4 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1513515

I am trying to:

I've created a form to allow users to create estimates. I've created a view that displays all of the products and services stored in the woocommerce products post type. I'd like users to be able to add multiple line items to the estimate form.

I've created a custom field for this that has the "Allow multiple instances of this field" option checked, and I'm using a cred generic field to display the options. Is there any way for a cred_generic_field to have the "Add New" button under it in the form as other single line fields can do?

Here is what the code for this generic field looks like so far:


<div class="row">
  <div class="col-sm-6"><label>Line Item</label>
      [cred_generic_field type='select' field='estimate-line-item' class='form-control' output='bootstrap' select_text='--- not set ---']
      {
      "required":1,
      "persist":1,
      "options":[wpv-view name="list-rep-line-items"]
      }
      [/cred_generic_field]
              </div>
</div>

Not the view works fine, it populates the drop down as expected. I'm currently attempting to duplicate the behavior by looking at single line fields that do allow multiple instances, and replicating the button and code that allows this, but thus far I've been unsuccessful.

Any help you can provide would be greatly appreciated.

Thanks,
Matt

#1514141

Hello,

The cred_generic_field shortcode supports two kinds of multiple choices fields:
- checkboxes
- multiselect
See our document:
https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_generic_field

And you will need to use action hook cred_save_data to save the user submitted values into your database as repeating field.

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/user-guides/custom-content/repeating-fields/#How%20Types%20Stores%20Repeater%20Fields

#1515065

Lou,

I'm confused by your answer, you said generic fields only support two types of multiple choice fields, and link to the documentation, but nowhere in the documentation does it say that is the case. This is just an observation as I don't need a multiple choice field in this instance, there will be far too many options in the list to do a multi-select or checkboxes field.

What I really need is a select field that allows for multiple instances of the field to be added to the post form, or a work around so I can create something close to that. I'm also open to other options that you think may be suitable for this use case as I'm sure it's not the first time someone has needed to create an estimate module with line items.

Thanks,
Matt

#1515717

I assume you are going to setup multiple instance generic field in Toolset form, if it is, there isn't such kind of built-in feature within Toolset Forms plugin, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#1516485

Thanks for looking into this for me Lou!