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?

View Replies:
mjamil4it replied on at Permalink Reply
You cannot achieve this by a custom template as form get rendered by calling this function:
$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.

<?php
defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
$hidden = ($view->getControlID() == 'akID[100][value]') ? 'display: none' : '';
?>
<div class="form-group" style="<?= $hidden ?>">
    <?php if ($view->supportsLabel()) { ?>
        <label class="control-label" for="<?=$view->getControlID()?>"><?=$view->getLabel()?></label>
    <?php } ?>
    <?php if ($view->isRequired()) { ?>
        <span class="text-muted small"><?=t('Required')?></span>
    <?php } ?>
    <?php
    if($view->getControlID() == 'akID[100][value]') {
        echo '<input type="text" id="akID[100][value]" name="akID[100][value]" value="'.$c->getCollectionName().'" placeholder="" class="form-control ccm-input-text">';