Jump to content

DanielD

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by DanielD

  1. Hello. Yes i did. I get the same 'null' result. Strangely this get->('value') or ->attr('value') works on select on another site.
  2. Hello. I have a problem regarding getting the selected select field value in a hook after a form is submitted but before the email is sent. I tried different ways: $form->getChildByName('store'); $form->getChildByName('store')->get('value'); $form->getChildByName('store')->get('selected'); When i dump these with bd() i get a result only on the first line. The other two returns 'null'. I looked everywhere on the forum, and documentation but can't figure out how to get the selected value. Thanks in advance. Daniel
  3. Hello. I can't add my image logo to the pdf when I generate the pdf in a hook. $pdf = $modules->get('RockPdf'); $forms->addHook('FormBuilderProcessor::emailFormReady', function($e) use ($pdf) { $pdf->write('<img style="width: 250px;" src="' . '/var/www/clients/client1/......./img.png' . '">'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); } ); This same thing works without a problem and adds the image to the pdf when it's generated outside of an event hook (in the admin I have the same pdf generator). But because I need to generate this pdf on form submit and send it with the mail. I need to generate it in the event hook. I tried absolute path, relative path, even base64 code (that too works in the admin pdf generator), but nothing seems to work when I try to use it here in the ready.php Hook.
  4. Thanks @kongondo. It works both ways, but it's better to use your way, because then I can load the PDF module only when I need it.
  5. Well it looks like that i solved it. We need to declare the $pdf variable outside the hooks, at the start of the file, and include it in the hooks. $pdf = $modules->get('RockPdf'); $forms->addHook('FormBuilderProcessor::emailFormReady', function($e) use ($pdf) { $pdf->write('TEST'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); } ); Not it works like a charm ?.
  6. Another thing that I found is than when I put the PDF code outside the $forms->addHook(); then it generates the PDF file. But if i try to put $pdf = $modules->get('RockPdf'); outside and $pdf->write('TEST'); and $pdf->save(); inside the hook then i get the same error..
  7. Hello. When i try to use $pdf = $modules->get('RockPdf'); in a form hook in /site/ready.php then i get an 500 Server Error. The hook without this line works, but when i include it then everything stops. When i insert everything for creating PDF in a template PHP file in /site/templates/ then it works correctly. It generates the PDF without error: $pdf = $modules->get('RockPdf'); $pdf->write('TEST'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); It's generated in /site/assets/RockPdf/generated_pdfs/. But this same thing in the /site/ready.php file throws an error: $forms->addHook('FormBuilderProcessor::emailFormReady', function($e) { $pdf = $modules->get('RockPdf'); $pdf->write('TEST'); $pdf->save('./generated_pdfs/' . date('yy-m-d_H_i') . '.pdf'); } ); I get this from the errors.txt log file: 2020-12-14 11:24:21 guest PAGENAME Fatal Error: Uncaught Error: Call to a member function write() on null in SITEPATH/site/assets/cache/FileCompiler/site/ready.php:36 Stack trace: #0 SITEPATH/wire/core/WireHooks.php(813): ProcessWire\ProcessWire->{closure}(Object(ProcessWire\HookEvent)) #1 SITEPATH/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\FormBuilderProcessor), 'emailFormReady', Array) #2 SITEPATH/site/modules/FormBuilder/FormBuilder/FormBuilderProcessor.php(1237): ProcessWire\Wire->__call('emailFormReady', Array) #3 SITEPATH/wire/core/Wire.php(386): ProcessWire\FormBuilderProcessor->___emailForm(Object(ProcessWire\InputfieldForm), Array) #4 SITEPATH/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___emailForm', Array) #5 SITEPATH/wire/core/Wire.ph (Zeile 36 in SITEPATH/site/assets/cache/FileCompiler/site/ready.php) If someone could help me, I would greatly appreciate it. My goal is to generate a PDF on form submission and attach it to the email that is sent to the admin. Thanks in advance. Daniel
×
×
  • Create New...