addText('name', 'Name')->required(); $form->addEmail('email', 'Email')->required()->confirm(); $form->addTextarea('message', 'Message')->required(); if ($form->isSubmitted() && $form->isValid()) { $name = $form->getData('name'); $email = $form->getData('email'); $message = $form->getData('message'); // Code to send email } ?>In the above example, PHP Form forTemplate is used to create form fields with validations and required inputs. The `isSubmitted()` and `isValid()` methods are used to check if the form has been submitted and if the input data is valid. The `render()` method is used to generate the HTML code for the form.