Adding page name field to form-express
Permalink
I've been working with the form-express block, however, when I put the express form block into a page type to prevent having 10 separate forms with the same questions, I can't see on which page a form has been submitted. I've looked into the code but wasn't sure if it is possible to add a hidden field containing the page name, so my question is:
Can and if yes how do I add a hidden field to an express-form which saves the page name?
Can and if yes how do I add a hidden field to an express-form which saves the page name?
If anybody is still interested in this, I have a new package in the marketplace that lets you do just that.
You can get the current page, current user, hidden checkboxes... and it's extendable so you can grab any information you want and send it along with your form.
https://www.concrete5.org/marketplace/addons/hidden-data-attributes-...
You can get the current page, current user, hidden checkboxes... and it's extendable so you can grab any information you want and send it along with your form.
https://www.concrete5.org/marketplace/addons/hidden-data-attributes-...
I did eventually fix it using Javascript, it was easier to do.
I made a new template for the express form with a javascript file added, with the following content:
update:
For this to work, I manually add a field to the form with the name url_hidden, this then gets searched by the javascript file, edited, and hidden.
I made a new template for the express form with a javascript file added, with the following content:
$(document).ready(function(){ $('.form-group:contains("url_hidden")').children(".form-control").attr("value", window.location.href); $('.form-group:contains("url_hidden")').hide(); });
update:
For this to work, I manually add a field to the form with the name url_hidden, this then gets searched by the javascript file, edited, and hidden.
I'm not sure I understand. What is "url_hidden"? As far as I know, Express forms don't let you give your fields attributes or anything like that so I'm not sure where "url_hidden" comes from. Could you explain, please?
And why don't you just hide it with CSS?
And why don't you just hide it with CSS?
It is a bit easier, I add a field to the form with the name:
url_hidden
Then the javascript file searches for that text, ads to the next field the URL of the page.
It then hides the entire parent div where the url_hidden field is in.
url_hidden
Then the javascript file searches for that text, ads to the next field the URL of the page.
It then hides the entire parent div where the url_hidden field is in.
A simple over ride can be done.
https://www.concrete5.org/community/forums/customizing_c5/include-pa...
Colin
https://www.concrete5.org/community/forums/customizing_c5/include-pa...
Colin
The drawback with this method is the data only appears in the email you receive. It will not be saved in the DB along with your Express object. So depending on the use case it might be okay or not.
$renderer->render();
You can only customize before and after the form see the documentation for more details:
https://documentation.concrete5.org/developers/express/express-forms...
Solution:
I have created an additional attribute in the form called PageName, idea is to make this field hidden with the page name its value.
Then I override the Application\elements\form\bootstrap3.php with the following, make sure you update the control id with your control id.