Enterprise forms set Subject Programatically in MailFormDataBehavior


I just trying to set the email subject using MailFormDataBehavior in Enterprise Forms programatically depending on HippoCMS locale.

I have a custom form class extending AutoDetectFormComponent and I’m unable to override getSubject method from MailFormDataBehavior. Other methods I’ve seen are read-only and I can just call the getters methods, not set the value.

I tried creating a new plugable form behavior based on MailFormDataBehavior which is a identical copy but in another package. Adding this new custom behavior I could change the getSubject method.
CustomMailFormDataBehavior extends MailFormDataBehavior

But the new class is not detected by HippoCMS, I attach screenshots of my configuration:

New custom behavior

Set the new behavior to the form component:

Hippo CMS can’t load the class:

Could you help with any clues?

Hi @aitoraznar

Do you got this error locally or in production ? For me it is because the class CMSMailFormDataBehavior has not been loaded by your JVM Runtime classloader. So where do you put the class in /site or /cms project ? are you sure that you have deployed it ?

Hi @ThoLe,

Thanks for your quick feedback.
I’m developing this locally, I have stopped, cleared the project (mvn clean) and compiled again.

The new custom class CustomMailFormDataBehavior is in /site. Additionally I have tried to move the class to /cms project with the same “class not found” result.

There is any way to set the email’s subject programatically? Maybe exists another simpler way to accomplish that.

Note: I renamed the classes to illustrate the sample

Tackling this in https://issues.onehippo.com/browse/SMC-43.

This can be closed