Skip Navigation

[Resolved] Field not unhooking when using conditional html output

This support ticket is created 5 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 13 replies, has 2 voices.

Last updated by Beda 5 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#1113077

I am trying to: https://pastebin.com/AfPCbi7d hide a specific post reference field, but unless it's visible, the field won't submit.

Link to a page where the issue can be seen:

I expected to see: the form submit. it does submit in edit mode although the checkbox for leadership does appear in edit mode.)

Instead, I got:

leadershiprelationship not present.
(and some other errors relating to other post reference fields, but I think that's a result of the lack of submission, not a bug in and of itself.)

Let me know if you need FTP access. WordPress access has been provided below.

#1113091

hidden link is the link to the form, to save time.

#1113483

The password submitted is incorrect, so the Login action tells me on the site you provided.
Can you revise it?
You should be able to edit the previous private reply, in case not, I activated a new one below

However the issue is not replicable locally, I tried as follows:
- created a required and a not required post relationships field with types
- created a required single line with types
- added this to a form, and hid the fields conditionally, shown only if a generic checkbox is 1
- if the field is hidden I can submit the form without requirements
- if I show the fields I have to add values - but here I found an issue, it seems the Post Reference Field does NOT respect the validation I set upon it, while single line does

I reported that, but it's exact opposite as what happens on your install, hence I would recommend to Update the plugins on the site you have first, as I suspect, by then you will run into the same exact issue as I did but will have the problem you reported resolved (however the field will not apply its requirement)

I reported this issue and the developers will look into it.

If the situation after updating is still the same, please do not forget to provide the log in data so I can have a look.

#1113632
#1114442

Hi,

I updated the plugins, and tested the form. It appeared to go much smoother, but my OR operator didn't seem to work. In other words, if I select departmental supervisor, I get the leadership prompt. If I select parent department supervisor, I do not.

I also do get a requirement to select department. Which reminds me... is there a way to change the sort order in the post reference fields?

#1114837

ERROR: The password you entered for the username toolsetsupport is incorrect.

Could you please adjust this so I can have a look, and link the forms, pages and other items I need to have a look at.

Thank you.

#1115096
#1115494

Yes, this new set of password worked.

On that site, WordPress and others (Plugins, Theme) are outdated, I'd suggest to update them.

On the Form you mention, I saw that you use AJAX submit (I did not use that).

However, I tested the form on a new Page and I can submit it just fine when the field is hidden.
I see you make that field not required, so there is no reason it should stop the form from submit and fail as required, as the description here says:
https://toolset.com/forums/topic/field-not-unhooking-when-using-conditional-html-output/#post-1113077

Of course, if you hide the field, the field has no value and won't update anything, as it's empty.
If you instead show it and populate it, it will be saved.

However as in the BUG, I reported to the Developers, validation will not apply currently to the Fields.
Means, the form will submit even if the field is required but empty.

During my report, I found that this does not only happen for Post Reference Fields but for all kind of Fields validated by Types as required.

If you encounter other issues, I suggest opening another ticket.

The problem that the field cannot be submitted if hidden, I could not replicate.
If I did the wrong steps, can you correct me where needed so I can try again?

I did insert the Form here:
hidden link

#1116656

Thank you so much Beda. the bulk of my problems went away when I updated Toolset, save one.

When you check "Department Supervisor", "Are you in Leadership" appears.

When you check "Parent Department Supervisor", it does not.

#1116988

WordPress is still outdated, this may imply a security risk, WordPress as well has BUGs and fixes them, I'd as soon as possible, update.

When you check "Department Supervisor", "Are you in Leadership" appears.

Not in my case, if I check Department Supervisor, nothing happens.

I need to select the Unit Supervisor?, Department Supervisor, then the Are you in Leadership appears.

I also see you have 2 forms in one form, like here:
hidden link

There are twice an entire Form Code set inside ([/credform])
This is wrong, it should be autogenerated again and then customized, as 2 forms in one won't work.

To solve the remaining issue please:
- set up a form where only that condition is inserted (and a Post Title input, and the required condition setting fields)
- then, insert that to a Page and link it to me, in case it still does not work as it should

I will then be able to pinpoint the issue and solve it

#1117330

Ok. Thank you.

The proper behavior of the form (the one I linked you to, which doesn't have duplicate code) is to have an OR statement, and to trigger if any supervisor checkbox is checked.

As for updating WordPress, you have a point, and I'll do that.

--Sam

#1117615

Please, as outlined, put the fields in a form so we can handle only them.

I cannot debug a Form that has at least 20 fields in there, which may affect this.
From there we can go further and see why it does not work.

I did so here and added a few conditions:
hidden link
hidden link

If Title "show", then show supervisorstaff
If supervisorstaff "1" (checked) then show parent-department-supervisor
If Title Show AND parent-department-supervisor 1 (checked) then show the whole chunk of Leadership Fields
These all work

Please add there what Conditional does not work based on what field, then we can adjust it.

==> Important, please note that you use conditions in Toolset > Post Fields as well, contrary to what I assumed due to the initial report stating there are no validations on those fields on Types side.
However there are, and those will apply over Forms, if not specifically determined else in the Form with Forms conditions, and I would not recommend to set conditions twice, it would be enough to set them in Types if you need them everywhere, or Forms if you need them only in forms

#1119187

I can't get the form you made to appear, using either your link or my own shortcode. My previous form does appear. Thanks for all your help.

#1119188

I added a logical OR to your code. My original has it, yours had a logical AND.

#1119189

I think there might be a duplicate slug.

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