Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Form Implementation

I'm using the Forms module in Fuel. I have it installed in the admin and in the database. However, I cannot figure out how to call the form I made. Do I have to create a layout for it in Fuel, or is it automatically generated.

The forms fields I have are:
Name
Email
Inquiry (drop down)
Message
Submit
Clear

Any help on the matter would be appreciated.

Comments

  • edited 5:16AM
    There is a form function you can call in which you pass it the key of your form:
    <?=form('my_form')?>

    That function is simply just a wrapper around:
    $CI =& get_instance(); echo $CI->fuel->forms->get('my_form')->render();
  • edited 5:16AM
    I got the form to show up, but when I test it I get an error:

    Fatal error: Call to a member function errors() on a non-object in /var/www/vhosts/osheaprint.com/httpdocs/fuel/modules/forms/controllers/Forms.php on line 60

    -----

    A PHP ERROR WAS ENCOUNTERED

    Severity: Error

    Message: Call to a member function errors() on a non-object

    Filename: controllers/Forms.php

    Line Number: 60

    Backtrace:
  • edited 5:16AM
    I was able to get it to display this message:


    Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
  • edited 5:16AM
    So it sounds like you were able to get the form to display but upon submission of the form you are getting the PHP mail error correct? If so, perhaps try this:
    https://stackoverflow.com/questions/3859958/codeigniter-unable-to-send-email-using-php-mail
  • edited March 15
    I have this for the code for my email.php page. The mail is setup through gsuite.
    public $protocol = 'smtp'; // mail/sendmail/smtp /** * STMP Server host * * @var string */ public $smtp_host = 'smtp.gmail.com'; /** * SMTP Username * * @var string */ public $smtp_user = 'email@osheaprint.com'; /** * SMTP Password * * @var string */ public $smtp_pass = '*********'; /** * SMTP Server port * * @var int */ public $smtp_port = 465; /** * SMTP connection timeout in seconds * * @var int */ public $smtp_timeout = 7; /** * SMTP persistent connection * * @var bool */ public $smtp_keepalive = TRUE; /** * SMTP Encryption * * @var string empty, 'tls' or 'ssl' */ public $smtp_crypto = 'ssl'; /** * Whether to apply word-wrapping to the message body. * * @var bool */ public $wordwrap = TRUE; /** * Number of characters to wrap at. * * @see CI_Email::$wordwrap * @var int */ public $wrapchars = 76; /** * Message format. * * @var string 'text' or 'html' */ public $mailtype = 'html'; /** * Character set (default: utf-8) * * @var string */ public $charset = 'iso-8859-1'; /** * Alternative message (for HTML messages only) * * @var string */ public $alt_message = ''; /** * Whether to validate e-mail addresses. * * @var bool */ public $validate = FALSE; /** * X-Priority header value. * * @var int 1-5 */ public $priority = 3; // Default priority (1 - 5) /** * Newline character sequence. * Use "\r\n" to comply with RFC 822. * * @link http://www.ietf.org/rfc/rfc822.txt * @var string "\r\n" or "\n" */ public $newline = "\r\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822) /** * CRLF character sequence * * RFC 2045 specifies that for 'quoted-printable' encoding, * "\r\n" must be used. However, it appears that some servers * (even on the receiving end) don't handle it properly and * switching to "\n", while improper, is the only solution * that seems to work for all environments. * * @link http://www.ietf.org/rfc/rfc822.txt * @var string */ public $crlf = "\n";
  • edited 5:16AM
    And this is the output when the form is sent - it shows up at the bottom of the page after the user presses send:


    220 smtp.gmail.com ESMTP l64sm13541012pfi.142 - gsmtp
    hello: 250-smtp.gmail.com at your service, [98.47.194.241]
    250-SIZE 35882577
    250-8BITMIME
    250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
    250-ENHANCEDSTATUSCODES
    250-PIPELINING
    250-CHUNKING
    250 SMTPUTF8
    from: 250 2.1.0 OK l64sm13541012pfi.142 - gsmtp
    data: 503 5.5.1 RCPT first. l64sm13541012pfi.142 - gsmtp
    The following SMTP error was encountered: 503 5.5.1 RCPT first. l64sm13541012pfi.142 - gsmtp
    reset: 250 2.1.5 Flushed l64sm13541012pfi.142 - gsmtp
    Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
    Date: Thu, 15 Mar 2018 20:22:14 -0700
    From: "Website Form Submission"
    Return-Path:
    Subject: =?UTF-8?Q?Message=20from=20Website?=
    Reply-To:
    User-Agent: CodeIgniter
    X-Sender: website@osheaprint.com
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <5aab38664b7ab@osheaprint.com>
    Mime-Version: 1.0


    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    The following information was submitted from the Contact form:

    Name: Name
    Email: ssl@ssl.com
    Message: Send us a message
    Url: http://osheaprint.com/forms/process/Contact
  • edited 5:16AM
    Are you directly editing the core library Email.php file? If so, I'd recommend either extending it with a fuel/application/libraries/MY_Email.php or create a fuel/application/libraries/email.php file.

    If you are seeing the email debugging message, it means the email wasn't sent (see line 1154 of fuel/modules/forms/library/Fuel_forms.php). You may have some issues with your SMTP settings. Also, if you want, I would test your mail outside of FUEL and using CodeIgniter's email library (which is what the Form module is using):
    https://www.codeigniter.com/user_guide/libraries/email.html
Sign In or Register to comment.