Search code examples
phpformsemailconcrete5concrete5-8.x

Form submission from specific page (Concrete5 8.3.2)


CMS: Concrete5 Version: 8.3.2

I added a Express Form Block in a Global Area. If someone fills out the form, I get a e-mail response. In the E-mail response it is not clear from what specific page the form is send. It only show the name of the form (same on all pages because of Global Area), the form results and link to result in the CMS.

So I need to insert something like $page->getCollectionName() in express_form > controller.php

I found a link (https://www.concrete5.org/community/forums/customizing_c5/form-submission-from-specific-page/#905411) but this is for an older version and does not seem work in the latest version.

Any Ideas?

EDIT SOLUTION:

Edited:block_express_form_submission.php

<?php

defined('C5_EXECUTE') or die("Access Denied.");

$formDisplayUrl = URL::to('/dashboard/reports/forms', 'view', $entity->getEntityResultsNodeId());
$c = Page::getCurrentPage();

$submittedData = '';
foreach($attributes as $value) {
    $submittedData .= $value->getAttributeKey()->getAttributeKeyDisplayName('text') . ":\r\n";
    $submittedData .= $value->getPlainTextValue() . "\r\n\r\n";
}

$body = t("
Form pagename: %s
Form name: %s 

%s

View all form results %s 

", $c->getCollectionName(), $formName, $submittedData, $formDisplayUrl);

Solution

  • concrete5 uses the /concrete/mail/block_form_submission.php email template to send notifications about Express Form submissions.

    You can customize this template by copying this file to the /application/mail folder and editing it.

    For instance, to add the page name, you could add these lines:

    $c = Page::getCurrentPage();
    $body .= "\n" . t('Page name: %s', $c->getCollectionName());