Override express form notifications
Permalink# concrete5 Version Core Version - 8.3.2 # PHP Version 5.6.10
I'm trying to sent extra info and an extra notification out form the express form.
By applying this to my package:
https://documentation.concrete5.org/developers/express/express-forms...
But got this error:
Class MySite\Express\Entry\Notifier\Notification\MyFormSubmissionEmailNotification contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Concrete\Core\Express\Entry\Notifier\NotifierInterface::getNotificationList, Concrete\Core\Express\Entry\Notifier\NotifierInterface::sendNotifications)
What am I missing?
Or is there another way to override the express form email notification function?
Error resolved but its not overriding the notifications.
MyFormSubmissionEmailNotification.php needs this too (or you get another error):
MyFormSubmissionEmailNotification.php needs this too (or you get another error):
use Concrete\Core\Express\Entry\Notifier\NotificationListInterface;
I can't really say why it's not overriding, I'd need to see your code. Can you attach it here?
I've attached it to the original post.
Oops sorry, I didn't see that.
Try this: in your package's controller, you have
version 5.8 doesn't actually exist, it should be
It might solve the problem as Concrete5 avoids using certain tools if the version required by the package is less than 8.0.
Try this: in your package's controller, you have
protected $appVersionRequired = '5.8';
version 5.8 doesn't actually exist, it should be
protected $appVersionRequired = '8.0';
It might solve the problem as Concrete5 avoids using certain tools if the version required by the package is less than 8.0.
This has no effect. Still not overriding.
(I attached it after my last reply. Not on initial post.)
(I attached it after my last reply. Not on initial post.)
Trying with xdebug to see where this goes wrong.
At some point gets touched. And nothing else.
It's something. ¯\_(ツ)_/¯
At some point
$controller = MySite\Express\Controller\FormController
It's something. ¯\_(ツ)_/¯
Not 100% sure but I think the standard controller is only used when choosing a driver and no driver to use is provided which might never be the case in normal usage.
Have you tried using bind instead of setStandardController? might work
Have you tried using bind instead of setStandardController? might work
Didn't work. I don't know what to try anymore. (Even overriding in application\src\Concrete\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification.php) won't get me anywhere.
Hey,
I just downloaded your .zip and have taken a look at it.
It should work if you follow the following steps:
Package controller is fine.
MySite\Express\Controller\FormController:
Remove the on_start method, you are already registering the FormController in the package controller.
Now add the following method:
Also add:
You may remove the entire FormNotifier.php file from you package.
MySite\Express\Entry\Notifier\FormNotifier
Let's edit MySite\Express\Entry\Notifier\Notification\MyFormSubmissionEmailNotification.
Instead of implementing NotifierInterface you can extend FormBlockSubmissionEmailNotification
So also add:
Now you can remove all the methods except the notify method.
The following os the notify method I sue for one of my clients use it or keep your own method:
Btw. You're not using the FormContext you added in your FormController so maybe it's wise to remove it if you are not planning on using it in the future.
I just downloaded your .zip and have taken a look at it.
It should work if you follow the following steps:
Package controller is fine.
MySite\Express\Controller\FormController:
Remove the on_start method, you are already registering the FormController in the package controller.
Now add the following method:
public function getNotifier(NotificationProviderInterface $provider = null) { $notifier = parent::getNotifier($provider); $notifier->getNotificationList()->addNotification(new MyFormSubmissionEmailNotification($this->app, $provider)); return $notifier; }
Also add:
use Concrete\Core\Express\Entry\Notifier\NotificationProviderInterface;
You may remove the entire FormNotifier.php file from you package.
MySite\Express\Entry\Notifier\FormNotifier
Let's edit MySite\Express\Entry\Notifier\Notification\MyFormSubmissionEmailNotification.
Instead of implementing NotifierInterface you can extend FormBlockSubmissionEmailNotification
So also add:
use Concrete\Core\Express\Entry\Notifier\Notification\FormBlockSubmissionEmailNotification;
Now you can remove all the methods except the notify method.
The following os the notify method I sue for one of my clients use it or keep your own method:
public function notify(Entry $entry, $updateType) { if ($this->blockController->notifyMeOnSubmission) { $mh = $this->app->make('mail'); $mh->to($this->getReplyToEmail($entry)); $mh->from('info@domain.nl'); $mh->replyto('info@domain.nl'); $mh->addParameter('entity', $entry->getEntity()); $mh->addParameter('formName', $this->getFormName($entry)); $mh->addParameter('attributes', $this->getAttributeValues($entry)); $mh->load('YOUR_MAIL_TEMPLATE','YOUR_PACKAGE_HANDLE'); $mh->setSubject(t('ClientName – %s', $this->getFormName($entry))); $mh->sendMail(); } }
Btw. You're not using the FormContext you added in your FormController so maybe it's wise to remove it if you are not planning on using it in the future.
Also, disable "Overrides Cache" while working on it.
Had to add this to the FormController.php but works.
How can I get the value of the express field [type=email] ?
Is one simple way.
Is there anything more dynamic available like getAttributeTypeHandle?
use MySite\Express\Entry\Notifier\Notification\MyFormSubmissionEmailNotification;
How can I get the value of the express field [type=email] ?
$entry->getEMail(); //handle = e_mail
Is one simple way.
Is there anything more dynamic available like getAttributeTypeHandle?
Add this to your class and it should work