I am trying to figure out how to create a simple Contact form so the user can send an email to us. This is in the Anonymous section of our web site - there is no login. I think this means I can’t use a transient entity?
I want to embed the form on my home page - it’s just three simple fields: name, email and message with a “Send” button.
In plain old HTML, that would just have a mailto link on the submit button for the form and it would be done.
Do I need to use a transient entity and a service to send the email via Cuba email sender? I know how to do that with the Generic UI but I just can’t wrap my head around React.
Sync up your frontend project model by running npm run update-model from the root of your frontend project. Your new method will appear in the restServices object located in <frontend-project-root>/src/cuba/services.ts.
In your form import restServices and call the corresponding method, providing form values as arguments.
Thanks. I created a simple service, ran npm run update-model, then tried to put the call into my form. I have based it on the PetClinic React test data generator example. I’m getting the following error:
TS2349: This expression is not callable.
I don’t know how to specify the arguments to the service call. See WHAT GOES HERE??? below:
Service interface:
public interface ContactEmailService {
String NAME = "pasweb_ContactEmailService";
public Boolean sendEmail(String name, String email, String message);
}