[Resolved] Split: Split: Filter posts with two parents – Forms API help required

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.

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 4 months, 2 weeks ago.

Assigned support staff: Minesh.


It looks great!! Later I'll test it.

Can you split this ticket, I've another issue with Validation, but I'd like you go on with it as you already knows the wp-admin setup if needed.

I've add and edit Timeslots forms. Both have the Bus parent field to connect the timeslot with a Bus.

What I need is to validete it to be sure it is not empty.

I tried this code, but it doesn't work for me:

function my_form_validate ($field_data, $form_data) {


  if ($form_data['id']==217) {
    $bus = $_POST['@bus-timeslot_parent'];
    if (empty($bus))
      log_me('Empty Bus');
      $errors['@bus-timeslot_parent'] = 'You have to select a Bus';
    } else {
      log_me('NO Empty Bus');

  return array($fields,$errors); 

What I would like to achive is that the user cannot submit the form if the parent field is not set. Another complications is that I have many forms on the same page.

This is the page:


This is the form:


This is the view that display forms:


thanks for the assistance.



Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The wp-admin access details you shared with the previous ticket is not working with I try to login as toolset user. Can you please send me that so I can troubleshoot this issue further.



Languages: English (English )

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

Ok - I've checked on your install and I found that you added the form to some popup.

It seems you are working on the site when I currently working. This will not help and take more time to troubleshoot the issue further.

First of all, I suggest you should separate the code you added. I've created another code snippet "toolset forms hook" where you should add all forms related hook and remove it from your "custom-functions" code snippet. You should reply here when you stop working on the site and I will start to investigate further.

Actually, Toolset form submits the data using PHP, this means that once you submit the form your page needs to refresh in order for the validations to run and return the errors.

I see you added the form to popup and form is set to submit so it will submit the form and refresh the page.

I suggest, to add some JS/jQuery code to make the parent field required and based on that you should enable and dislable the submit button that will be a really easy way to do so.


Thaks for your answer. Now we stop working on the website. I moved all the forms code to "toolset forms hook".

I like your suggestion about validate by jQuery. The difficulty is how to work on select2 select and that we have many forms on the same page. Can you help me with a jQuery example?



Languages: English (English )

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

To implement the jQuery it needs custom code that is above and beyond the scope of our support policy.

However, I've added the following code to your form's JS box that will actually help you to locate the ID of your HTML select field. You can take it as reference:

 id =  $('select[name="@bus-timeslot.parent"]').prop('id');