I have a class with a signature:
class CRM_Contact_Form_Task_FooPdf extends CRM_Contact_Form_Task {
What generates a PDF. During the PDF generation, there might be an error. This task also uses the standard mail template:
public function buildQuickForm() {
// Add message templates.
CRM_Mailing_BAO_Mailing::commonCompose($this);
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js', 0, 'html-header');
$this->addDefaultButtons(ts('Continue'), 'done', 'cancel');
}
It works totally fine. It shows up among the actions on a search form, when I select it, the template UI shows up, and i have access to the data. The only issue is that during the PDF generation, sometimes I need to raise an error, which is not a fatal error, but something that the user must correct himself. At the PDF generation, i am in the \CRM_Core_Form::postProcess() phase. Can I set a form error and re-display the form with the submitted values?
Issuing this (and of course skip to stream the PDF) does not work, as I am redirected simply to the main admin page of CiviCRM, the form is not re-generated:
$this->setElementError('text_message', 'moo');
But I guess it's because i am already at the postprocessing.