Jump to content

Flashmaster82

Members
  • Posts

    166
  • Joined

  • Last visited

Recent Profile Visitors

1,332 profile views

Flashmaster82's Achievements

Sr. Member

Sr. Member (5/6)

19

Reputation

  1. Thanks for the fast and great reply. // Email $email = new \FrontendForms\InputEmail('scf_email'); // make usage of InputEmail $email->setLabel($fields->get('scf_email')->$label); $email->setRule('required'); $form->add($email); I think this made the trick!!
  2. <?php namespace Processwire; $contact_form = $pages->get("template=contact"); $company = $pages->get("template=company"); $form = new \FrontendForms\Form('Form'); $form->setHtml5Validation(true); // Enable HTML5 browser validation // First Name $firstname = new \FrontendForms\InputText('scf_firstname'); $firstname->setLabel($fields->get('scf_firstname')->$label); $firstname->setRule('required'); $form->add($firstname); // Last Name $lastname = new \FrontendForms\InputText('scf_lastname'); $lastname->setLabel($fields->get('scf_lastname')->$label); $lastname->setRule('required'); $form->add($lastname); // Phone $phone = new \FrontendForms\InputText('scf_phone'); $phone->setLabel($fields->get('scf_phone')->$label); $phone->setRule('required'); $form->add($phone); // Email $email = new \FrontendForms\InputText('scf_email'); $email->setLabel($fields->get('scf_email')->$label); $email->setRule('required'); $form->add($email); // SERVICES $service = new \FrontendForms\Select('scf_service'); $service->setLabel(__($fields->get('scf_service')->$label)); // Add options dynamically based on existing pages $services = wire('pages')->find('template=insurance|telephony|pension, sort=name'); // Add options dynamically based on existing pages foreach ($services as $servicePage) { $service->addOption($servicePage->title, $servicePage->id); } $form->add($service); $message = new \FrontendForms\Textarea('scf_message'); $message->setLabel($fields->get('scf_message')->$label); $message->setRule('required'); $form->add($message); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', $fields->get('label_send')->label); $button->setAttribute('class', 'btn btn-primary'); // Add the CSS class $form->add($button); if($form->isValid()){ $p = new Page(); $p->template = 'contact_inquiry'; $p->parent = wire('pages')->get('template=contact'); $p->title = $form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname'); $p->scf_firstname = $form->getValue('scf_firstname'); $p->scf_lastname = $form->getValue('scf_lastname'); $p->scf_phone = $form->getValue('scf_phone'); $p->scf_email = $form->getValue('scf_email'); $p->scf_service = $form->getValue('scf_service'); $p->scf_message = $form->getValue('scf_message'); // Set the scf_date field to the current date and time with the correct timezone $dateTime = new \DateTime('now', new \DateTimeZone('Europe/Stockholm')); $p->scf_date = $dateTime->format('Y-m-d H:i:s'); $p->save(); // Retrieve the title of the selected legal service $selectedserviceID = $form->getValue('scf_service'); $selectedservice = wire('pages')->get($selectedserviceID); $selectedserviceTitle = $selectedservice ? $selectedservice->title : 'Not specified'; // Initialize $messageBody $messageBody = ''; $m = wireMail(); $m->to('test@gmail.com'); $m->subject("{$contact_form->scf_email_title} {$selectedserviceTitle}, {$form->getValue('scf_firstname')} {$form->getValue('scf_lastname')}"); // Set "Reply-To" address $m->header('Reply-To', $form->getValue('scf_email') . ' (' . $form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname') . ')'); $messageBody .= "<strong>{$fields->get('scf_firstname')->label}:</strong> " . $form->getValue('scf_firstname') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_lastname')->label}:</strong> " . $form->getValue('scf_lastname') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_phone')->label}:</strong> " . $form->getValue('scf_phone') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_email')->label}:</strong> " . $form->getValue('scf_email') . "<br><br>"; $messageBody .= "<strong>{$fields->get('scf_service')->label}:</strong> " . $selectedserviceTitle . "<br><br>"; $messageBody .= "<strong>{$fields->get('scf_message')->label}</strong><br>" . $form->getValue('scf_message') . "<br>"; $m->bodyHTML($messageBody); $m->send(); // Set up the email for the form submitter $confirmationEmail = wireMail(); $confirmationEmail->to($form->getValue('scf_email')); $confirmationEmail->subject("{$contact_form->scf_email_confirmation_title} {$selectedserviceTitle}"); $confirmationMessage = "{$contact_form->scf_email_confirmation_message}"; $confirmationEmail->bodyHTML($confirmationMessage); $confirmationEmail->send(); // Redirect to the success page wire('session')->redirect(wire('config')->urls->root . 'arendet-skickades/'); } echo $form->render(); ?> When i insert like XX into the email field there is an error Error: Exception: Invalid email address (in E:\Wamp\www\website\wire\core\WireMail.php line 162). I dont know how to validate the email adress before sending the form. Any clues?
  3. Can´t install this module: ProcessModule: Module is not installable because not all required dependencies are currently met. What other modules do i need to install to get this to work?
  4. Can´t install my site with the downloaded duplicated version. Duplicator 1.5.2. Processwire 3.0.229 Deprecated: strrpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in E:\Wamp\www\..\installer.php on line 709
  5. <?php namespace Processwire; $form = new \FrontendForms\Form('myForm'); $firstname = new \FrontendForms\InputText('scf_firstname'); $firstname->setLabel($fields->get('scf_firstname')->$label); $firstname->setRule('required'); $form->add($firstname); $lastname = new \FrontendForms\InputText('scf_lastname'); $lastname->setLabel($fields->get('scf_lastname')->$label); $lastname->setRule('required'); $form->add($lastname); $phone = new \FrontendForms\InputText('scf_phone'); $phone->setLabel($fields->get('scf_phone')->$label); $phone->setRule('required'); $form->add($phone); $email = new \FrontendForms\InputText('scf_email'); $email->setLabel($fields->get('scf_email')->$label); $email->setRule('required'); $form->add($email); $legalservice = new \FrontendForms\Select('scf_legalservice'); $legalservice->setLabel(__($fields->get('scf_legalservice')->$label)); // Add options dynamically based on existing pages $legalservices = wire('pages')->find('template=legal_service'); foreach ($legalservices as $service) { $legalservice->addOption($service->title, $service->id); } $form->add($legalservice); $message = new \FrontendForms\Textarea('scf_message'); $message->setLabel($fields->get('scf_message')->$label); $message->setRule('required'); $form->add($message); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', $fields->get('label_send')->label); $form->add($button); if($form->isValid()){ $p = new Page(); $p->template = 'contact_inquiry'; $p->parent = wire('pages')->get('template=contact'); $p->title = $form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname'); $p->scf_firstname = $form->getValue('scf_firstname'); $p->scf_lastname = $form->getValue('scf_lastname'); $p->scf_phone = $form->getValue('scf_phone'); $p->scf_email = $form->getValue('scf_email'); $p->scf_legalservice = $form->getValue('scf_legalservice'); $p->scf_message = $form->getValue('scf_message'); // Set the scf_date field to the current date and time with the correct timezone $dateTime = new DateTime('now', new DateTimeZone('Europe/Stockholm')); $p->scf_date = $dateTime->format('U'); // 'U' format returns the Unix timestamp $p->save(); $m = wireMail(); $m->to('info@...'); // please change it $m->subject('Nytt ärende'); $messageBody .= "<strong>{$fields->get('scf_firstname')->label}:</strong> " . $form->getValue('scf_firstname') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_lastname')->label}:</strong> " . $form->getValue('scf_lastname') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_phone')->label}:</strong> " . $form->getValue('scf_phone') . "<br>"; $messageBody .= "<strong>{$fields->get('scf_email')->label}:</strong> " . $form->getValue('scf_email') . "<br>"; // Retrieve the title of the selected legal service $selectedLegalServiceID = $form->getValue('scf_legalservice'); $selectedLegalService = wire('pages')->get($selectedLegalServiceID); $selectedLegalServiceTitle = $selectedLegalService ? $selectedLegalService->title : 'Not specified'; $messageBody .= "<strong>{$fields->get('scf_legalservice')->label}:</strong> " . $selectedLegalServiceTitle . "<br>"; $messageBody .= "<strong>{$fields->get('scf_message')->label}:</strong> " . $form->getValue('scf_message') . "<br>"; $m->bodyHTML($messageBody); $m->send(); // Redirect to the success page wire('session')->redirect(wire('config')->urls->root . 'forfragan-skickades/'); } echo $form->render(); ?>
  6. I think the problem was $m->from('noreply@...'); but im not sure.. I´m facing a new problem though.. I can´t get it to redirect after sending?
  7. I think i got it to work now, maybe a misspelling or something. Thanks for the help.
  8. This is so strange. Now with your code im receiving email. But with this code i will not receive any email? <?php namespace Processwire; ?> <div class="container col-5 tmar10"> <?php $form = new \FrontendForms\Form('myForm'); $firstname = new \FrontendForms\InputText('scf_firstname'); $firstname->setLabel(__($fields->get('scf_firstname')->label)); $firstname->setRule('required'); $firstname->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($firstname); $lastname = new \FrontendForms\InputText('scf_lastname'); $lastname->setLabel(__($fields->get('scf_lastname')->label)); $lastname->setRule('required'); $lastname->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($lastname); $phone = new \FrontendForms\InputText('scf_phone'); $phone->setLabel(__($fields->get('scf_phone')->label)); $phone->setRule('required'); $phone->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($phone); $email = new \FrontendForms\InputText('scf_email'); $email->setLabel(__($fields->get('scf_email')->label)); $email->setRule('required'); $email->setRule('email'); $email->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($email); $legalservice = new \FrontendForms\Select('scf_legalservice'); $legalservice->setLabel(__($fields->get('scf_legalservice')->label)); // Add options dynamically based on existing pages $legalServices = wire('pages')->find('template=legal_service'); foreach ($legalServices as $service) { $legalservice->addOption($service->title, $service->id); } $legalservice->setAttribute('class', 'w3-select w3-border w3-margin-bottom'); $form->add($legalservice); $message = new \FrontendForms\Textarea('scf_message'); $message->setLabel(__($fields->get('scf_message')->label)); $message->setRule('required'); $message->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($message); $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', __($fields->get('label_send')->label)); $button->setAttribute('class', 'w3-btn w3-round w3-blue'); $button->addWrapper()->setAttribute('class', 'w3-padding-24 w3-center'); $form->add($button); if ($form->isValid()) { // Form data is valid, save to a new page $p = new Page(); $p->template = 'contact_inquiry'; $p->parent = wire('pages')->get('template=contact'); $p->title = $form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname'); $p->scf_firstname = $form->getValue('scf_firstname'); $p->scf_lastname = $form->getValue('scf_lastname'); $p->scf_phone = $form->getValue('scf_phone'); $p->scf_email = $form->getValue('scf_email'); $p->scf_legalservice = $form->getValue('scf_legalservice'); $p->scf_message = $form->getValue('scf_message'); // Set the scf_date field to the current date and time $p->scf_date = time(); $p->save(); // send an email $m = wireMail(); $m->to('info@....com'); $m->subject(_('New message from the contact form')); $m->fromName($form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname')); $m->from('noreply@....se'); // Customize the email message body $messageBody = "First Name: " . $form->getValue('scf_firstname') . "<br>"; $messageBody .= "Last Name: " . $form->getValue('scf_lastname') . "<br>"; $messageBody .= "Phone: " . $form->getValue('scf_phone') . "<br>"; $messageBody .= "Email: " . $form->getValue('scf_email') . "<br>"; $messageBody .= "Legal Service: " . $form->getValue('scf_legalservice') . "<br>"; $messageBody .= "Message: " . $form->getValue('scf_message') . "<br>"; $m->bodyHTML($messageBody); if($m->send()){ print_r('send'); } } echo $form->render(); ?> </div> Email is changed. I have got some help from ai chat.
  9. The print output the success message. I tried with your simple form and it print out Thank you for your message. But no email received? Shouldn´t i insert some send email "noreply@...
  10. Thanks again for the reply, i tried the update it will make a new page and there is a success message. Im using Frontendform module btw. But im not receiving any mail? hmm.. Is there any settings in the Frontendform module that is important? noreply email? Do i need to install any other module to make this work? i only have the Frontendform module.
  11. Thanks for the reply. I changed to your other module Frontendform and everything works accept im not receiving any email? the email in this code changed btw. <?php namespace Processwire; ?> <div class="container col-5 tmar10"> <?php $form = new \FrontendForms\Form('contactform'); $form->setSuccessMsg(__('Your message was submitted successfully!')); $form->setErrorMsg(__('Sorry, but there are errors!')); $firstname = new \FrontendForms\InputText('scf_firstname'); $firstname->setLabel(__($fields->get('scf_firstname')->$label)); $firstname->setRule('required'); $firstname->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($firstname); $lastname = new \FrontendForms\InputText('scf_lastname'); $lastname->setLabel(__($fields->get('scf_lastname')->$label)); $lastname->setRule('required'); $lastname->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($lastname); $phone = new \FrontendForms\InputText('scf_phone'); $phone->setLabel(__($fields->get('scf_phone')->$label)); $phone->setRule('required'); $phone->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($phone); $email = new \FrontendForms\InputText('scf_email'); $email->setLabel(__($fields->get('scf_email')->$label)); $email->setRule('required'); $email->setRule('email'); $email->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($email); $legalservice = new \FrontendForms\Select('scf_legalservice'); $legalservice->setLabel(__($fields->get('scf_legalservice')->$label)); // Add options dynamically based on existing pages $legalServices = wire('pages')->find('template=legal_service'); foreach ($legalServices as $service) { $legalservice->addOption($service->title, $service->id); } $legalservice->setAttribute('class', 'w3-select w3-border w3-margin-bottom'); $form->add($legalservice); $message = new \FrontendForms\Textarea('scf_message'); $message->setLabel(__($fields->get('scf_message')->$label)); $message->setRule('required'); $message->setAttribute('class', 'w3-input w3-border w3-margin-bottom'); $form->add($message); // Note: scf_date is not added as a form field, but it will be set when saving the new page $button = new \FrontendForms\Button('submit'); $button->setAttribute('value', __($fields->get('label_send')->$label)); $button->setAttribute('class', 'w3-btn w3-round w3-blue'); $button->addWrapper()->setAttribute('class', 'w3-padding-24 w3-center'); $form->add($button); if ($form->isValid()) { // Form data is valid, save to a new page $p = new Page(); $p->template = 'contact_inquiry'; $p->parent = wire('pages')->get('template=contact'); $p->title = $form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname'); $p->scf_firstname = $form->getValue('scf_firstname'); $p->scf_lastname = $form->getValue('scf_lastname'); $p->scf_phone = $form->getValue('scf_phone'); $p->scf_email = $form->getValue('scf_email'); $p->scf_legalservice = $form->getValue('scf_legalservice'); $p->scf_message = $form->getValue('scf_message'); // Set the scf_date field to the current date and time $p->scf_date = time(); $p->save(); // send an email $m = wireMail(); $m->to('myemail@gmail.com'); $m->fromName($form->getValue('scf_firstname') . ' ' . $form->getValue('scf_lastname')); $m->from($form->getValue('scf_email')); $m->subject(_('New message from the contact form')); $m->bodyHTML($form->getValue('scf_message') . ' <br><br> ' . $form->getValue('scf_address')); $m->send(); // Redirect to the success page wire('session')->redirect(wire('config')->urls->root . 'forfragan-skickades/'); } echo $form->render(); ?> </div>
  12. How do you choose other fields? I want a form like First name, Last name, Phone, Email, Service (dropdown select), Message.
×
×
  • Create New...