Prefill Express-Form

Permalink
I have an expressform, that is used on many product-detail-pages on my website.
There's a support-form realized with express form.

How can I prepopulate a field "referring product" with an attribute of the current page?

I'm looking for a way in my custom view.php of the express-form.

Michael

maschenborn
View Replies: View Best Answer
mnakalay replied on at Permalink Best Answer Reply
mnakalay
There is no easy way to do that. You'd have to code your way through it. Here's the doc that explains how to modify the view of an Express form.https://documentation.concrete5.org/developers/express/express-forms...

Maybe look specifically at the part to modify the "required" text as it's probably the same steps as what you'd have to do.

Otherwise, there might be a better solution. Easier in any case. If you want that field to be automatically filled I suppose you don't want the user to mess with it or modify it. If that's the case I suggest you have a look at my package Express Hidden Data
https://www.concrete5.org/marketplace/addons/hidden-data-attributes-...

It adds several hidden attributes types to your form. The one that would work for you is the dynamic data one because it is extendable. Look at the bottom of the page there's a link to a GitHub repo with an example, it's really easy.

So basically you can have it grab the page attribute, output the value to a hidden field and it's submitted along witht he form. No user input and no user interference.

If you think it could solve your problem and have any questions, feel free to post here or ping me by Private Message.
maschenborn replied on at Permalink Reply
maschenborn
This is exactly what I was looking for. Thank you.

One problem is the output in the email:
In reports / submitted forms you can read the pagename and username and timestamp.
In the email there's only the collection-ID, user-ID and a timestamp-hash.

Could you output this in a readable format?
mnakalay replied on at Permalink Reply
mnakalay
That's actually not under my package's control, it's how the email template is set in Concrete5.
It's pretty easy to change but it will make your email an HTML email instead of a plain text email and will show the data exactly as in the report with links and all.

If you can live with that I'll send you a modified email template and will show you how to use it.
maschenborn replied on at Permalink Reply
maschenborn
HTML is fine! Please send me the template. Thank you
mnakalay replied on at Permalink Reply
mnakalay
Actually, please dismiss my previous comment. I implemented it directly in the package. Turns out it was the right thing to do :)

Update to version 1.0.3 and you should be good to go.

And if you like the package and it saves you time and effort I'd really appreciate it if you could leave a review (https://www.concrete5.org/marketplace/addons/hidden-data-attributes-for-express/reviews).

No pressure whatsoever of course ;-)