Hi again, looking at the link you sent me, I still don't understand how to create the form.
"Create forms in the CMS, as static views or a combination of the two" where in the CMS?
"Below is an example of adding a hook in the configuration file of a form:" what is a configuration file of a form? Where is it? Do I need to create it? if so, where do I save it?
"Using the 'form' helper function // load the helper ... $CI is CI object obtained from the get_instance(); and automatically passed to blocks $CI->load->module_helper(FORMS_FOLDER, 'forms');
Where do I use it? In a controller? In a page in the cms? in a view?
"To add the form to a page in the CMS, you will need to add the "form" function to the $config['parser_allowed_functions'] configuration in the fuel/application/config/MY_fuel.php file" Add it how?
So as you can see, I don't understand the process at all.
Ok, I created a block with the form (I want to display the form on the home page)
The form's action is: mysite/contact/process
I have a contact controller and in it I have a function: process.
In the Email.php file I have this: public $mailpath = '/usr/sbin/sendmail'; // Sendmail path public $protocol = 'mail'; // mail/sendmail/smtp
In MY_Config I have this (for local testing): $config['dev_email'] = Array( 'protocol' => 'smtp', 'smtp_host' => 'mailtrap.io', 'smtp_port' => 2525, 'smtp_user' => 'my-user', 'smtp_pass' => 'my-password', 'authentication' => 'cram_md5', 'crlf' => "\r\n", 'newline' => "\r\n" );
On the live server I get Page not Found.
On the local server I get: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
The easiest way to test out the form is to copy the fuel/modules/forms/config/forms.php file into fuel/application/config/forms.php. Then go to the forms area of the config and add your configuration. Then in create a file in fuel/application/views/test.php added the following: <?=form('my_form')?> Where 'my_form' is the key given to the form in the config.
I changed my approach and downloaded the demo site from the user guide.
I put these details in the Email file: var $mailpath = ""; var $protocol = "smtp"; var $smtp_host = "ssl://smtp.googlemail.com"; var $smtp_user = "myuser"; var $smtp_pass = "mypass"; var $smtp_port = "465"; var $smtp_timeout = 5; var $smtp_crypto = ""; var $wordwrap = TRUE; var $wrapchars = "76"; var $mailtype = "html"; var $charset = "iso-8859-1";
Tried to send the contact form from my local pc, got this: Message: fsockopen(): SSL: Handshake timed out
Filename: libraries/Email.php
Line Number: 1690
In my php.ini I have this line: extension=php_openssl.dll
I also tried to follow what was done in this site, and found out I need to create these tables: forms and form_entries which I am not interested in, don't need to save any form entries.
Also, what is the $config['dev_email'] for in the MY_Config file?
Sorry, another question, which version of ci is the demo site using?
I uploaded the site to my live server (php version 7) and I get this error: Message: Declaration of MX_Loader::library($library, $params = NULL, $object_name = NULL) should be compatible with CI_Loader::library($library = '', $params = NULL, $object_name = NULL)
Hi Sigal, I recently began putting Fuel CMS sites onto PHP 7 servers, and it would be easier to use Fuel v1.4 (which includes CI v3.1.3). You need to ensure that libraries, models and controllers have filenames that match their class names exactly eg controllers/Contact.php (not controllers/contact.php). Otherwise copying the newest version's fuel/modules/fuel/ folder over the old is a good start, but obviously, files in /application will need to be changed suitably too.
Re environment settings & email you could do something like:
$email_cfgs = [
'development' => [
'protocol' = 'sendmail',
'mailpath' = '/usr/sbin/sendmail',
'charset' = 'iso-8859-1',
'wordwrap' = TRUE,
],
'production' => [
... different settings...
]
];
$this->email->initialize($email_cfgs[ENVIRONMENT]);
I'm not sure where you want to place the initialization (in a controller, library, config) so you might need to adjust, eg for a config/email.php you would only need:
Thank you Gumster. The problem is I can't understand how to do the contact form, so I downloaded the demo site and it seems it is on php 5.6. The new site I'm trying to develop is on php7
I just can't get it to work, and I can't follow the documentation. I don't understand it. Gumster, would you be interested to code the form for me for payment?
If you don't need or care about the user / admin being able to define custom forms, then be aware there are other ways of providing contact forms. Generally I would create my own controller, use Form_builder class to create a form from a config file and set the rendered HTML as a variable sent to the controller's view. This is very much inline with regular Codeigniter principles. The controller would include the validation rules (if any, for the form) and the validated POST can then be emailed, post processed or whatever. But you lose (somewhat) the flexibility of the Forms module, having a block that can be rendered anywhere, etc.
I'm using the Forms module exactly for those admin functionality reasons, and it seems to work fine, but I am using v1.4, PHP7 and storing the form config in the Forms module db table. There was a hiccup I encountered early on, but that has been fixed now.
I'd be interested in helping out, you can use this forum to send a message via my profile page if you are still stuck.
To get the form into the block, you should just need the form helper - it calls on Form_builder class to render the form as HTML (and populate with any posted values too).
Comments
http://docs.getfuelcms.com/modules/forms
"Create forms in the CMS, as static views or a combination of the two" where in the CMS?
"Below is an example of adding a hook in the configuration file of a form:" what is a configuration file of a form? Where is it? Do I need to create it? if so, where do I save it?
"Using the 'form' helper function
// load the helper ... $CI is CI object obtained from the get_instance(); and automatically passed to blocks
$CI->load->module_helper(FORMS_FOLDER, 'forms');
echo form('myform', array('fields' => array('name' => array('required' => TRUE)));"
Where do I use it? In a controller? In a page in the cms? in a view?
"To add the form to a page in the CMS, you will need to add the "form" function to the $config['parser_allowed_functions'] configuration in the fuel/application/config/MY_fuel.php file"
Add it how?
So as you can see, I don't understand the process at all.
Any way you can help please?
The form's action is: mysite/contact/process
I have a contact controller and in it I have a function: process.
In the Email.php file I have this:
public $mailpath = '/usr/sbin/sendmail'; // Sendmail path
public $protocol = 'mail'; // mail/sendmail/smtp
In MY_Config I have this (for local testing):
$config['dev_email'] = Array(
'protocol' => 'smtp',
'smtp_host' => 'mailtrap.io',
'smtp_port' => 2525,
'smtp_user' => 'my-user',
'smtp_pass' => 'my-password',
'authentication' => 'cram_md5',
'crlf' => "\r\n",
'newline' => "\r\n"
);
On the live server I get Page not Found.
On the local server I get:
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Can you please help?
Just to confirm, you downloaded the module from the following URL and installed it per the instructions on that page?
https://github.com/daylightstudio/FUEL-CMS-Forms-Module
The easiest way to test out the form is to copy the fuel/modules/forms/config/forms.php file into fuel/application/config/forms.php. Then go to the forms area of the config and add your configuration. Then in create a file in fuel/application/views/test.php added the following:
<?=form('my_form')?>
Where 'my_form' is the key given to the form in the config.
I changed my approach and downloaded the demo site from the user guide.
I put these details in the Email file:
var $mailpath = "";
var $protocol = "smtp";
var $smtp_host = "ssl://smtp.googlemail.com";
var $smtp_user = "myuser";
var $smtp_pass = "mypass";
var $smtp_port = "465";
var $smtp_timeout = 5;
var $smtp_crypto = "";
var $wordwrap = TRUE;
var $wrapchars = "76";
var $mailtype = "html";
var $charset = "iso-8859-1";
Tried to send the contact form from my local pc, got this:
Message: fsockopen(): SSL: Handshake timed out
Filename: libraries/Email.php
Line Number: 1690
In my php.ini I have this line:
extension=php_openssl.dll
I also tried to follow what was done in this site, and found out I need to create these tables: forms and form_entries which I am not interested in, don't need to save any form entries.
Also, what is the $config['dev_email'] for in the MY_Config file?
Thank you very much for all the help.
I uploaded the site to my live server (php version 7) and I get this error:
Message: Declaration of MX_Loader::library($library, $params = NULL, $object_name = NULL) should be compatible with CI_Loader::library($library = '', $params = NULL, $object_name = NULL)
Filename: MX/Loader.php
Line Number: 0
https://www.getfuelcms.com/blog/2017/03/17/fuel-cms-1-4-released
There's a command line utility that might be of use mentioned in the above link.
You might be able to downgrade your PHP on the server also (to v5.5/6). But best to get used to PHP7!
$email_cfgs = [ 'development' => [ 'protocol' = 'sendmail', 'mailpath' = '/usr/sbin/sendmail', 'charset' = 'iso-8859-1', 'wordwrap' = TRUE, ], 'production' => [ ... different settings... ] ]; $this->email->initialize($email_cfgs[ENVIRONMENT]);
I'm not sure where you want to place the initialization (in a controller, library, config) so you might need to adjust, eg for a config/email.php you would only need:
$dev = [ 'protocol' => 'sendmail', 'mailpath' => '/usr/sbin/sendmail' ...etc.. ]; $prod = [ 'protocol' => 'smtp', 'smtp_port' => 25 ...etc.. ]; $config = (ENVIRONMENT == 'production') ? $prod : $dev;
<?=$__antispam___field?>
I get this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: __antispam___field
Filename: _blocks/contact_form.php
I have the forms file under config:
$config['forms']['forms'] = array(
'contact' => array('javascript_validate' => TRUE, 'javascript_submit' => FALSE, 'form_display' => 'block', 'block_view' => 'contact_form', 'form_builder' => array('required_text' => ''),
'fields' => array(
'first_name' => array('required' => TRUE),
'surname' => array('required' => TRUE),
'email' => array('required' => TRUE),
'phone',
'message' => array('type' => 'textarea'),
),
)
);
I just can't get it to work, and I can't follow the documentation. I don't understand it. Gumster, would you be interested to code the form for me for payment?
In my forms.php file I have this:
$config['forms']['forms'] = array(
'contact' => array('javascript_validate' => TRUE, 'javascript_submit' => FALSE, 'form_display' => 'block', 'block_view' => 'contact_form', 'form_builder' => array('required_text' => ''),
'fields' => array(
'first_name' => array('required' => TRUE),
'surname' => array('required' => TRUE),
'email' => array('required' => TRUE),
'phone',
'message' => array('type' => 'textarea'),
'anti_spam_method' => array('method' => 'recaptcha', 'recaptcha_site_key' => 'my-site-key',
'recaptcha_secret_key' => 'my-secret-key', 'theme' => 'white'),
),
)
);
In views/_blocks/contact_form I tried:
1. <?php
$this->fuel->forms->get('contact'); ?>
No form displays.
2.
$CI->load->module_helper(FORMS_FOLDER, 'forms');
echo form('contact', array('fields' => array('name' => array('required' => TRUE))));
I get:
Severity: Notice
Message: Trying to get property of non-object
Filename: libraries/Fuel_forms.php
Line Number: 1216
I really don't understand, how do I get the form from the forms.php into my view block?
3. foreach($fields as $field) : ?>
<?=$field['label']?>
<?=$field['field']?>
<?php endforeach; ?>
Severity: Notice
Message: Undefined variable: fields
Filename: _blocks/contact_form.php
Line Number: 2
I really need help with this, I'm approaching the site's deadline and just cannot understand the documentation.
If you don't need or care about the user / admin being able to define custom forms, then be aware there are other ways of providing contact forms. Generally I would create my own controller, use Form_builder class to create a form from a config file and set the rendered HTML as a variable sent to the controller's view. This is very much inline with regular Codeigniter principles. The controller would include the validation rules (if any, for the form) and the validated POST can then be emailed, post processed or whatever. But you lose (somewhat) the flexibility of the Forms module, having a block that can be rendered anywhere, etc.
I'm using the Forms module exactly for those admin functionality reasons, and it seems to work fine, but I am using v1.4, PHP7 and storing the form config in the Forms module db table. There was a hiccup I encountered early on, but that has been fixed now.
I'd be interested in helping out, you can use this forum to send a message via my profile page if you are still stuck.