A ClassNotFoundError occurs when submitting the form

Thank you for your continued support.

I’m using ConcreteCMS 9.4.8 with the Atomik theme.
I configured the Express form as usual, but when I test submitting, I get the error shown in the image.

I don’t plan to use any paid form add-ons, so I would appreciate it if you could provide an answer using the core form.

I would like to know why I need to use a form, so I would appreciate your guidance.

The FormBlockSubmissionEmailNotification class is defined in the Concrete\Core\Express\Entry\Notifier\Notification namespace: see this line.

So, its full name is

Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification

When you want to use that class, you have two alternatives:

  1. write the full class, with its namespace. For example:
    new \Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification(...);
    
  2. tell PHP that you want to use FormBlockSubmissionEmailNotification as a shorthand of that long name:
    // At the beginning of your file
    use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;
    
    // Then you can write
    new FormBlockSubmissionEmailNotification(...);
    
    
    

In any case, when you want to create a Concrete class, it’s better to create it with app(): that way you don’t have to pass the class constructor all the parameters it requires, but only the needed ones.

For example, in your case I’d write:

// At the beginning of your file
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;

// Then you can write
$notifications = [
    $this->app->make(FormBlockSubmissionEmailNotification::class, ['blockController' => $this]),
];

Thank you for your guidance.

I’m not very knowledgeable about this, so I don’t understand what you’re saying.

I apologize.

This site isn’t newly created, so I’ll try installing ConcreteCMS 9.4.8 from scratch.

I’ll let you know the results.

Thank you for your understanding.

The error was not one of the files of the standard ConcreteCMS: it was in the custom file located at /application/blocks/express_form/controller.php.
That’s the file you should fix.

Thank you for your continued support.

Upon checking, I found that you were correct.

I had customized the system to implement an automatic reply form, and it works correctly on other sites.

However, when I applied the same settings to a newly installed site with ConcreteCMS 9.4.8, an error occurred.

I believe I had previously used the settings described in a case I saw on this forum, and there had been no problems until now.

Currently, an error is being displayed.

<?php
namespace Application\Block\ExpressForm;
use Concrete\Block\ExpressForm\Controller as CoreController;
use Application\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionNotification;
class Controller extends CoreController
{ 
public function getNotifications() 
{ 
$notifications = [new FormBlockSubmissionEmailNotification($this->app, $this)]; 
//if we don't save data we must not use this notifier because entry is already not saved 
if ($this->areFormSubmissionsStored()) { 
array_unshift($notifications, new FormBlockSubmissionNotification($this->app, $this)); 
} 
return $notifications; 
}
}

I changed line 6 of controller.php from
use Application\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;
to use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;
The error disappeared, but I’m not receiving any email replies.

<?php

namespace Application\Block\ExpressForm;

use Concrete\Block\ExpressForm\Controller as CoreController;
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionNotification;

class Controller extends CoreController
{
    public function getNotifications()
    {
        $notifications = [new FormBlockSubmissionEmailNotification($this->app, $this)];
        //if we don't save data we must not use this notifier because entry is already not saved
        if ($this->areFormSubmissionsStored()) {
            array_unshift($notifications, new FormBlockSubmissionNotification($this->app, $this));
        }

        return $notifications;
    }
}
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;

The file structure is as shown in the image.

application/blocks/express_form/controller.php

application/mail/block_express_form_submission
application/mail/block_express_form_submission_user

block_express_form_submission.php

<?php

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

/**

 * @var Concrete\Core\Entity\Express\Entity $entity
 * @var string $formName
 * @var bool|int|string|null $dataSaveEnabled
 * @var Concrete\Core\Entity\Attribute\Value\ExpressValue[] $attributes
 * @var Concrete\Core\Entity\Express\Entry\Association[] $associations
 */
if (!isset($associations)) {
    $associations = [];
}

$formDisplayUrl = $entity->getEntryListingUrl();

$subject = t('site name – %s', $formName);

$submittedData = '';
foreach ($attributes as $value) {
    if ("image_file" != $value->getAttributeTypeObject()->getAttributeTypeHandle() || ($dataSaveEnabled && "image_file" == $value->getAttributeTypeObject()->getAttributeTypeHandle())) {
        $submittedData .= $value->getAttributeKey()->getAttributeKeyDisplayName('text') . ":\r\n";
        $submittedData .= $value->getPlainTextValue() . "\r\n\r\n";
    }
}
foreach ($associations as $association) {
    $submittedData .= $association->getAssociation()->getTargetEntity()->getEntityDisplayName() .  ":\r\n";
    $selectedEntries = $association->getSelectedEntries();
    foreach ($selectedEntries as $selectedEntry) {
        $submittedData .= $selectedEntry->getLabel() . "\r\n";
    }
    $submittedData .= "\r\n";
}

if ($dataSaveEnabled) {
    $body = t("
There has been a submission of the form %s through your Concrete website.

%s

To view all of this form's submissions, visit %s 

", $formName, $submittedData, $formDisplayUrl);
} else {
    $body = t("
There has been a submission of the form %s through your Concrete website.

%s
", $formName, $submittedData);
}

block_express_form_submission_user.php

<?php

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

$formDisplayUrl = URL::to('/dashboard/reports/forms', 'view', $entity->getEntityResultsNodeId());
/**
 * @var $entity \Concrete\Core\Entity\Express\Entity
 * @var $associations \Concrete\Core\Entity\Express\Entry\Association[]
 */
if (!isset($associations)) {
    $associations = [];
}

$subject = t('Thank you for submitting the form.');

$submittedData = '';
foreach ($attributes as $value) {
    if ("image_file" != $value->getAttributeTypeObject()->getAttributeTypeHandle() ||
 ($dataSaveEnabled && "image_file" == $value->getAttributeTypeObject()
->getAttributeTypeHandle())) {
        $submittedData .= $value->getAttributeKey()->getAttributeKeyDisplayName('text') . ":\r\n";
        $submittedData .= $value->getPlainTextValue() . "\r\n\r\n";
    }
}

foreach ($associations as $association) {
    $submittedData .= $association->getAssociation()->getTargetEntity()->getEntityDisplayName() .  ":\r\n";

    $selectedEntries = $association->getSelectedEntries();

    foreach ($selectedEntries as $selectedEntry) {

        $submittedData .= $selectedEntry->getLabel() . "\r\n";

    }

    $submittedData .= "\r\n";
}

$body = t("

—————————————————————————————————————————————————————
■□%sReceived□■
—————————————————————————————————————————————————————

—————————————————————————————————————————————————————
■Submitted content
—————————————————————————————————————————————————————
%s
—————————————————————————————————————————————————————
Please note that this is an automated reply email. 
—————————————————————————————————————————————————————
Company name, etc.

", $formName, $submittedData);

This is the content of the file.

Thank you for your guidance.