Concrete 5.7 Form Blocks - form validation works in a Page but not in a Stack

Permalink
Hi,

When I add a form block to a page, everything works fine.

When I add a similar form to a stack and add the stack to a page, the form will work as long as the *required* fields are complete. If they are not complete, the page refreshes but the error messages are not injected into the page.

I have tried this on a couple of different installs of C5. I have swapped from my custom theme to the default Elemental theme but the problem persists.

Anybody else experience this problem? Is it a bug?

Anyone know how to fix this?

Many thanks!

*****************************
Relevant Info:

# No errors showing in browser console

# Concrete5 Version = 5.7.5.6

# Cache Settings = everything Off

# PHP Version = 5.5.28

# Packages = Block Custom Styles (0.9).

SmoothPixel
 
Gondwana replied on at Permalink Reply
Gondwana
I think it's a bug. c5.7's Form block uses bID to track instances, but bID doesn't necessarily identify a particular instance, such as after Stack operations.

I wrote a form handler for a specific requirement that didn't rely on bID, but it was a big job.

I understand that c5.8 has a different Form block; you could try that (on a full c5.8 install).
SmoothPixel replied on at Permalink Reply
SmoothPixel
Hi Gondwana

Thanks for your reply - it's great to have confirmation that it's a bug.

I have a C5.6 site where I have done this and it works perfectly. I accept what you're saying, but if it works in c5.6 surely it can be made to work in c5.7?

As far as I can tell the form works fine - it's just the form validation stuff that's not working. Looks like I'm going to have to write some custom Javascript to highlight the *required fields (when it's submitted incomplete).

Unfortunately this is a production site so c5.8 isn't an option - yet!
Gondwana replied on at Permalink Reply
Gondwana
I gather that the problem with bID was introduced relatively recently; see
https://www.concrete5.org/community/forums/customizing_c5/unique-blo...

...so perhaps 5.6 doesn't suffer this problem.

One solution may be to avoid using copy/paste (hence clipboard, stacks, etc). It's more work and means repeating yourself, but should ensure that each form gets its own bID (which is used to detect responses from the block controller for success and error reporting).

A long shot: I wonder if the c5.8 Form block would work in c5.7. You could try packaging it.
SmoothPixel replied on at Permalink Reply
SmoothPixel
Thanks for the link - very informative!

I still think it must be a bug in C5.7's Form Block. For one thing, if there are no errors in the form, the page successfully injects the form confirmation notice. Surely if it knows which block instance to do this for, then it should be able to do the same for the validation error messages too?

Also, C5.6 has a clipboard and stacks, and from what I've read the Form Block hasn't changed much for 5.7. If it works for 5.6, it should work for 5.7.

I'm hoping I have found a solution by using a Global Area to reproduce the form on the required pages. The form now seems to be working normally.

The reason I didn't do this originally is Global Areas are less flexible than Stacks. The beauty of the stack is that you can set it up as default content within a page template. The page editors are then free to reposition it or remove it from each page as they see fit.

Thanks for your suggestions, but the Global Area is a better solution - if it works! I'll let you know how I get on.
Gondwana replied on at Permalink Best Answer Reply
Gondwana
I don't disagree that it's a bug. I get the impression that c5.7 introduced the ability for multiple 'renderings' (appearances) of the same block to be done without actually duplicating the block, which meant that each rendering had the same bID. The Form block needed to change between 5.6 and 5.7 more than it did, to take this behaviour into account.

I can't see why your global area solution won't work, because in this case you shouldn't be dealing with multiple 'renderings', so bID will uniquely identify the Form.
andrew replied on at Permalink Reply
andrew
This does indeed appear to be a bug with the form in 5.7. This will be fixed in version 8 when using the updated form block.
SmoothPixel replied on at Permalink Reply
SmoothPixel
Hi Andrew

Thanks for the confirmation. It's great to hear this will be fixed in version 8.

I'm guessing it will be some time before version 8 is ready for production sites?

Is there any point in me logging this in the bug tracker for 5.7 in the meantime?
ramonleenders replied on at Permalink Reply
ramonleenders
Version 8 went Beta today/yestday (or tonight whatever lol). It's the first beta, so it will take a while till the first release. Expect to have a little bugs here and there that weren't discovered yet (as with every "big" release). So I wouldn't use version 8 on a production site (my opinion, maybe others think differently). If you plan on developing this site with a deadline 3/4 months from now, you can start with version 8 I guess. Should be pretty much fixed and updated by then. So depends on your situation if version 8 is the way to go.
SmoothPixel replied on at Permalink Reply
SmoothPixel
Hi Ramon

Thanks for the update. I'm updating a live C5.7 website so version 8 Beta isn't an option for me.

Is version 8 going to have an easy upgrade path from v7?
OKDnet replied on at Permalink Reply
OKDnet
Yes, the upgrade to version 8 will be an easy update as in the past (before v. 7).
SmoothPixel replied on at Permalink Reply
SmoothPixel
Excellent news!
SmoothPixel replied on at Permalink Reply
SmoothPixel
As a quick follow up, here's how I got my form working in the end:

The form had to be available on every page of the site via a pop-up. I used C5's built in Magnific Popup for this. I tried to use a Global Area to contain the form (initially hidden via CSS) but it wouldn't work as the form's submission/validation requires a POST to the page. This reloads the page and closes the Popup.

The solution was to create a separate page (based on a new, minimal template) to contain the form. This form page is loaded into Magnific Popup via the iFrame option. Form submissions now reload seamlessly in the Popup's iFrame.

This works well and the client is very happy with it. The only (minor) issue is that I have had to specify a fixed height for the popup (as it can't easily find the dimensions of the iFrame's content). This leaves a gap at the bottom of the form to allow for the confirmation/validation messages. Without the gap, the feedback messages trigger a scroll bar on the iFrame - not a huge problem, just unsightly.

Thanks everyone for your help.