justb3a

Simple Contact Form

238 posts in this topic

Hello justb3a,

at the moment I try to build my first website with processwire and so I need a simple contactform.

I found your module and it works fine. But I have a problem to fit the module to my bootstrap form.

Can you explain me (i'm a beginner) how i can realize this. This would be wonderful.

Thanks and many greetings from Berlin

Share this post


Link to post
Share on other sites

hello gebeer,

thank you for your response.

I tried to change it, but in the moment it is not so easy for me. To many new things I have to learn.

Maybe you can help me.

I tried to put the class: col-sm-8 to an input field. How can I do this? Changing the "item_content" in the class-array didn't work. 

 

   Webbrowser:  <input id="Inputfield_scf_email" class=" required" name="scf_email" type="text" size="60">

Maybe you have an example for a correct array?

 

Many Greetings

Lena

Share this post


Link to post
Share on other sites

Hi,

it seems that `item_content` only apply to inputfields of type InputfieldWrapper and InputfieldPage. 

If you use something like `_init.php` you can add a hook there:

$this->addHookBefore('Inputfield::render', function(HookEvent $event) {
  if ($this->page->template->name === 'contact') { // adapt template name to compare with
    $inputfield = $event->object;
    $inputfield->addClass('col-sm-8');
    $event->return = $inputfield;
  }
});

 

1 person likes this

Share this post


Link to post
Share on other sites

Hi all!

This module works great and I don't have any errors. I was just wondering if there is any option to send an e-mail with the data filled in the form in a template. So you receive at the end an e-mail with a logo and maybe more adjustments. Or should I add the logo in the module file to the message and maybe style it there too?

-EDIT-

My contractor haves an alias of a gmail account. So the e-mail adres looks like name@companyname.com but it is from google. Now I want to send the emails to that email address, but he receives nothing. Also not in the spambox. Is it possible that this doesn't work because the emailadress is an alias or is it something else? 

To present more information, the website I am currently working on was a few years ago moved from a hosting service to another hosting company. Now I noticed that the email in the current hosting application has the wrong records, but the e-mailadresses are still working and don't experience any problems, except for not receiving the contact form e-mail.

Does anyone know how this is possible, is it because the records are wrong (but emailaddressess still work fine) or is it a bug in the module?

Thanks in advance,

~Harmen

Edited by Harmen
Additional errors

Share this post


Link to post
Share on other sites
12 hours ago, ank said:

Hello

is there a way to make some fields required ?

Sure, you only have to check the required checkbox in the field settings.

required.png

1 person likes this

Share this post


Link to post
Share on other sites

justb3a, thanks for such a lovely script! :-)

This works perfectly with SimpleContactForm 1.0.0 on Processwire 3.0.42

<?php $scf = $modules->get('SimpleContactForm'); 
    $options = array(
	'btnClass' => 'button fit big',
	'btnText' => 'SEND MESSAGE!',
	'successMessage'  => 'Message Sent!',
	'errorMessage'  => 'Sorry - message send error!'
);
echo $scf->render($options); ?>

But if you just use this (without specifiying the successmessage) e.g.

<?php $scf = $modules->get('SimpleContactForm'); 
$options = array(
	'btnClass' => 'button fit big',
	'btnText' => 'SEND MESSAGE!'
);
echo $scf->render($options); ?>

The form processes (send) correctly, but the form output on the web page after sending is shown as:

<p class='form--success--message'>SEND MESSAGE!</p>

Showing the 'btnText', rather than the correct 'default success message'.

Have I missed someting obvious?

I've posted just incase anyone else is having the same issues.

1 person likes this

Share this post


Link to post
Share on other sites

@dab Could you please pull the latest version from branch develop? I fixed this already some time ago but haven't released it yet.

1 person likes this

Share this post


Link to post
Share on other sites

For some sites the "spam message" might not be approprate :lol:

So I changed line 215 in SimpleContactForm.module to

            $this->_("Sorry, but your message didn't pass our %s test. Please try another %s."),

and change lines 155 (& the following) & 172 (& the following) in \lib\SpamProtection.php to

      $this->_('spam'),

and

      $this->_('time'),

 

So the message will read " Sorry, but your message didn't pass our spam test. Please try another time. "

Thanks again @justb3a

Share this post


Link to post
Share on other sites

@dab It's not that good idea to change something inside a third-party module (or, even worse, in the core). If you update the module, all your changes get lost.
I would suggest translating the values  – which will be inserted – with 'spam' and 'time'. You could also translate "Sorry, but your message didn't pass our %s test. Please try another %s." with "Sorry, but your message didn't pass our spam test. Please try another time.". Therefore I made them translatable. ^_^

1 person likes this

Share this post


Link to post
Share on other sites

Hello, Im having some problems with simple contact form styling. I tried everything but just don't get it. I went throu THIS pages but can't figure it out what should I actually do to make it the way I want. I tried and played with this but no success. Im not a coder but understand some ...

My HTML looks like this:
 


	<form action="#" method="post">
		<div class="input-field">
			<input type="text" name="name" class="form-control" placeholder="Your Name...">
		</div>
		<div class="input-field">
			<input type="email" name="email" class="form-control" placeholder="Your Email...">
		</div>
		<div class="input-field">
			<input type="text" name="Phone" class="form-control" placeholder="Phone Number...">
		</div>
		<div class="input-field">
			<textarea name="message" class="form-control" placeholder="Messages..."></textarea>
		</div>
		<button type="submit" id="submit" class="btn btn-blue btn-effect">Send</button>
	</form>

Any help is appreciated.

Thank you

R

Share this post


Link to post
Share on other sites

hi roych,

you should be as clear as possible in your questions. you don't explain what the problem is. you could add screenshots how it is and how it should be. styling is usually done via CSS. answers depend a lot on your setup...

1 person likes this

Share this post


Link to post
Share on other sites

Sorry for not being clear enough. I would like to style my form created in  SimpleContactForm module. But I can't figure it out how from those instructions. Where and how should I change classes in my code.

expl.

My code for showing a form now, looks like this. 

<?php echo $modules->get('SimpleContactForm')->render(); ?>

this is giving me some basic style from PW. How do I change those styles so it would look like the form posted in first post?

I tried and played with this

$scf = $modules->get('SimpleContactForm');

$options = array(
  'markup' => array(
    'list' => "<div {attrs}>{out}</div>",
    'item' => "<p {attrs}>{out}</p>"
  ),
  'classes' => array(
    'form' => 'form form__whatever',
    'list' => 'list-item'
  )
);

echo $scf->render($options);

but can't figure it out how this should work. There is no changes no mather what I do ...  And where is the Style for submit button etc.?

I hope I was more clear this time.

Thank you

R

Edited by kongondo
Your question is about module that has its own support forum. I have moved your thread to that support forum.

Share this post


Link to post
Share on other sites

Hi,

I've migrated a Processwire site that was running on PW 2.6.1 with SCF 0.1.1 to a new installation of PW 3.0.42 and after I install SCF 1.0.0 I'm getting the following error which breaks the admin:

 

Error: [] operator not supported for strings (line 131 of ...\site\modules\Processwire-SimpleContactForm\SimpleContactForm.module)

Line 131 of that file is ->     foreach (self::$additionalFields as $f) $allFieldsExtended[] = $f;

 

When I remove the [] from that line (which I don't suspect for a second is an actual fix, but at least makes the admin functional again) the module shows as installed and all of my previously created fields appear in red on the settings screen under "Select form fields". Is there something I need to do to those old fields? There's mention of upgrade notes on the first page of the thread here but none of the links work.

Share this post


Link to post
Share on other sites

I haven't used this module, so not sure about those red fields, but I think the likely correct fix for the operator not supported issue is to to define $allfields in the additional fields at around line 65.

protected $allFields = array();

 

1 person likes this

Share this post


Link to post
Share on other sites

Thanks, Adrian. That got rid of the error message.

Unfortunately, it seems that a lot of functionality's been lost and with the gaping documentation gaps this isn't going to work for me.

Share this post


Link to post
Share on other sites

Why its not working?

Email is displayed as not valid, but it is. Turn yellow -> not sending...

How to turn off website and date? I hide it per css buts dirty…

using 1.0

tom

 

Share this post


Link to post
Share on other sites

I can't figure the [FAILURE] Number of fields does not match issue at all.

I have 5 fields:-

  • scf_firstname
  • scf_surname
  • scf_email
  • scf_company
  • scf_enquiry

PW ver. 3.0.33

SCF ver. 1.0.0

Any help greatly appreciated.

Share this post


Link to post
Share on other sites

@Roych

Try this:

$scf = $modules->get('SimpleContactForm');

$options = array(
  'btnClass' => 'btn btn-blue btn-effect',
  'btnText' => 'Send',
  'classes' => array(
    'item' => 'input-field'
  )
);

$content .= $scf->render($options);

You need to set the placeholder in the field settings, go to Admin > Setup > Fields > Edit Field: xxx > Tab Input > Placeholder Text.
It's recommended to hide the label using css (label { display: none; }). People which have to use screen readers will reward you ^_^

Unfortunately it's not that easy to add the class form-control to every input field. There is no way to set it globally.
I would suggest using css to achieve what you want:

.input-field input,
.input-field textarea,
.input-field select {
  // your styling goes here
}

Otherwise you have to hook into every render function for every fieldtype you use and pass the class inside the getAttributesString function

 

Share this post


Link to post
Share on other sites

@alexmercenary I found a little bug: The module uses a imaginary field named 'date'. Normally there is no 'date' field (naive assumption, I know) and everything works as expected. But if you create a field named 'date' for something else, the condition matches and the form has one more field than desired. The same counted for a field named 'ip'. I just released a new version 1.0.1. Please try if it's working now.

@Tom Walcher

On 24/02/2017 at 7:01 PM, Tom Walcher said:

Email is displayed as not valid, but it is. Turn yellow -> not sending...

How to turn off website and date? I hide it per css buts dirty…

The form just validates every field how it is configured in the field settings. If you want to have email validation, set the field type to email. If you want a field to be required, just check the corresponding checkbox in the field settings. Same counts for html5 validation.

Hiding the website and date field via CSS is not dirty. The website field is already of type hidden, so you just have to hide the corresponding label. The website field is intentional not hidden. It's a trap for spambot. Have a look at the documentation.

 

1 person likes this

Share this post


Link to post
Share on other sites
On 23/02/2017 at 3:40 AM, adrian said:

I haven't used this module, so not sure about those red fields, but I think the likely correct fix for the operator not supported issue is to to define $allfields in the additional fields at around line 65.


protected $allFields = array();

 

I would not recommend doing this. 'allfields' is already declared in the moduleConfig file. If you set it in the module file again, this value will be overwritten and if you render the form all fields are gone. ^_^

@Arcturus

On 23/02/2017 at 6:01 PM, Arcturus said:

Unfortunately, it seems that a lot of functionality's been lost and with the gaping documentation gaps this isn't going to work for me.

Feel free to optimise the documentation! Fixes and suggestions are very welcome!
A lot has been changed since version 0.1.1. I think, this is the page you were looking for, but this is no longer relevant. Because the module now renders the form by itself and no template adaptions are needed any longer. Did you try to render the form (frontend)? If not, please do so. There are some migration functions in the module. If you still want to use this module, please post the input of the column data from table modules where column 'class' equals SimpleContactForm. Furthermore some additional informations would be really good (save messages enabled? fields which should be added, ..).

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By psy
      ProcessWire DropboxAPI on GitHub: https://github.com/clipmagic/DropboxAPI
       
      This module is a wrapper for Kunal Varma's Dropbox PHP SDK https://github.com/kunalvarma05/dropbox-php-sdk
      It was created to perform a specific function for a client, ie upload PDF files on a PW website to a specific Dropbox account folder.
      The PDF files, created using @Wanze's excellent PagesToPdf module using the WirePDF functions, are generated from Formbuilder forms completed by front-end site visitors.  Works a treat!
      There's more that could be done to allow ProcessWire to take advantage of all the features of the SDK, eg downloads, multiple Dropbox accounts, etc. You are welcome to request changes and/or fork the GitHub project to extend the feature set.
      Enjoy!
      System requirements
      PHP 5.6.4 or greater Composer The PHP mbstring extension General information
      This module enables you to access a single Dropbox (www.dropbox.com) account to upload files from a ProcessWire website.
      All kudos to (https://github.com/kunalvarma05/dropbox-php-sdk) for the PHP API.
      First steps
      Visit (https://www.dropbox.com/developers) and read the documentation. Log into Dropbox and create a new application. It's recommended to limit ProcessWire App access to a specified folder Make a note of the App key, the App secret and the name of the Dropbox folder Installation
      Download the zip file into your site/modules folder then expand the zip file. Next, login to ProcessWire > go to Modules > click "Refresh". You should see a note that a new module was found. Install the DropboxAPI module. Configure the module with your App key, App secret and your Call Back URL You need to generate a Dropbox access token to enable your site to communicate with the nominated Dropbox account. Dropbox will generate a token for you or you can create a page for the front end of your ProcessWire site with a template to submit the token request to Dropbox, eg:
      <?php namespace ProcessWire; $drop = $modules->get('DropboxAPI'); if ($input->get->code && $input->get->state) { $code = $sanitizer->text($input->get->code); $state = $sanitizer->text($input->get->state); //Fetch the AccessToken $accessToken = $drop->getAccessToken($code, $state); echo "Copy/paste this code into the module configuration: " . $accessToken; } else { echo "<p><a href='" . $drop->getAuthURL() . "'>Log in with Dropbox</a></p>"; } ?> Once you have entered the token in the module configuration, you can unpublish this page.
      Usage
      Read the dropbox-php-sdk documentation!
      An example template for sending a file to a Dropbox App folder from ProcessWire:
      <?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; // send pdf to Dropbox $drop = $modules->get('DropboxAPI'); $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); if ($app) { //Configure Dropbox service $dropbox = new Dropbox($app); $dropboxFile = new DropboxFile('/path/to/myfilename.pdf'); $file = $dropbox->upload($dropboxFile, "/myfilename.pdf", ['autorename' => true]); //Uploaded File meta data if ($file) { $success = $file->getName() . " uploaded to Dropbox"; $drop->log($success); } }  
       
    • By sirhc
      Hi all,
      Im trying to install this core module and got the error of not having the ImageMagick library installed.
      But if im checking for the version of my ImageMagick installed on my server via SSH im getting this response;
      identify -version
      Version: ImageMagick 6.9.4-9 Q16 i386 2016-06-21 http://www.imagemagick.org
      Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
      License: http://www.imagemagick.org/script/license.php
      Features: Cipher DPC 
      Delegates (built-in): bzlib freetype gslib jng jpeg png ps tiff xml zlib
      Does this even mean the library is installed? And if yes, why cant i install my module?
      Pleaassee help me
      Greetz.
    • By kixe
      FieldtypeColor is on github

      Fieldtype stores a 32bit integer value reflecting a RGBA value.
      Input
      5 types of Inputfields provided
      Html5 Inputfield of type='color' (if supported by browser)    Inputfield type='text' expecting a 24bit hexcode string (RGB). Input format: '#4496dd'.
      The background color of the input field shows selected color Inputfield of type='text' expecting 32bit hexcode strings (RGB + alpha channel) Input format: '#fa4496dd' Inputfield with Spectrum Color Picker
      (Options modifiable) Inputfield type='text' with custom JavaScript and/or CSS (since version 1.0.3) Output
      Define output format under 'Details' tab in field settings. Select from the following 8 options
      string 6-digit hex color. Example: '#4496dd' string 8-digit hex color (limited browser support).  Example: '#fa4496dd' string CSS color value RGB. Example: 'rgb(68, 100, 221)' string CSS color value RGB. Example: 'rgba(68, 100, 221, 0.98)' string CSS color value RGB. Example: 'hsl(227, 69.2%, 56.7%)' string CSS color value RGB. Example: 'hsla(227, 69.2%, 56.7%, 0.98)' string 32bit raw hex value. Example: 'fa4496dd' int 32bit. Example: '4198799069' (unformatted storage value) The Fieldtype includes
      Spectrum Color Picker by Brian Grinstead

      SCREENSHOTS
      Input type=text with changing background and font color (for better contrast)

      Input type=color (in Firefox)


      Javascript based input (Spectrum Color Picker)


      Settings Output

       
      Settings Input

    • By zlitrox
      Hi!
      I'm relatively new to the world of Processwire, but so far I'm really impressed by this CMS and its ease, power and speed.
      I've been looking at the different field types and also existing CKEditor modules (pwimage and pwlink).
      Here's what i want to achieve:
      I would like to use or create a own module which allows my admin users to upload pdf files inline in a CKEditor field (page content) the same way images are handled. It should be possible to upload a pdf file and specify its name and from the file uploaded and name i want to show an icon or image inline in editor and the output for that upload should be customized based on the module. Lets make it simple and say that i upload datasheet-1.pdf and want it to be named "My product datasheet", i want the output to be:
      <a href="{ link to uploaded pdf file }">My product datasheet</a>  
      Also the uploaded pdf files should be related to the page the user is editing.
       
      Is this doable? 
       
      Any guidance would be greatly appreciated! Thanks in advance.
      PS. I'm a PHP programmer so i know it would require some custom code, but the real question is where do i start, what should it take and is it even possible to do?
    • By flydev
      Auth2Login for ProcessWire
      A Module which give you ability to login an existing user using your favorite thrid-party OAuth2 provider (i.e. Facebook, GitHub, Google, LinkedIn, etc.)..
      You can login from the backend to the backend directly or render a form on the frontend and redirect the user to a choosen page.
      Built on top of ThePhpLeague OAuth2-Client lib.
      Registration is not handled by this module but planned.
       
      Howto Install
      Install the module following this procedure:
       - http://modules.processwire.com/modules/oauth2-login/
       - https://github.com/flydev-fr/OAuth2Login
      Next step, in order to use a provider, you need to use Composer to install each provider
      ie: to install Google, open a terminal, go to your root directory of pw and type the following command-line: composer require league/oauth2-google
      Tested providers/packages :
          Google :  league/oauth2-google     Facebook: league/oauth2-facebook     Github: league/oauth2-github     LinkedIn: league/oauth2-linkedin
      More third-party providers are available there. You should be able to add a provider by simply adding it to the JSON config file.

      Howto Use It
      First (and for testing purpose), you should create a new user in ProcessWire that reflect your real OAuth2 account information. The important informations are, Last Name, First Name and Email. The module will compare existing users by firstname, lastname and email; If the user match the informations, then he is logged in.
      ie, if my Google fullname is John Wick, then in ProcessWire, I create a new user  Wick-John  with email  johnwick@mydomain.com
      Next step, go to your favorite provider and create an app in order to get the ClientId and ClientSecret keys. Ask on the forum if you have difficulties getting there.
      Once you got the keys for a provider, just paste it into the module settings and save it. One or more button should appear bellow the standard login form.
      The final step is to make your JSON configuration file.
      In this sample, the JSON config include all tested providers, you can of course edit it to suit your needs :
      { "providers": { "google": { "className": "Google", "packageName": "league/oauth2-google", "helpUrl": "https://console.developers.google.com/apis/credentials" }, "facebook": { "className": "Facebook", "packageName": "league/oauth2-facebook", "helpUrl": "https://developers.facebook.com/apps/", "options": { "graphApiVersion": "v2.10", "scope": "email" } }, "github": { "className": "Github", "packageName": "league/oauth2-github", "helpUrl": "https://github.com/settings/developers", "options": { "scope": "user:email" } }, "linkedin": { "className": "LinkedIn", "packageName": "league/oauth2-linkedin", "helpUrl": "https://www.linkedin.com/secure/developer" } } }  
      Backend Usage
      In ready.php, call the module :
      if($page->template == 'admin') { $oauth2mod = $modules->get('Oauth2Login'); if($oauth2mod) $oauth2mod->hookBackend(); }  
      Frontend Usage
      Small note: At this moment the render method is pretty simple. It output a InputfieldForm with InputfieldSubmit(s) into wrapped in a ul:li tag. Feedbacks and ideas welcome!
      For the following example, I created a page login and a template login which contain the following code :
      <?php namespace ProcessWire; if(!$user->isLoggedin()) { $options = array( 'buttonClass' => 'my_button_class', 'buttonValue' => 'Login with {provider}', // {{provider}} keyword 'prependMarkup' => '<div class="wrapper">', 'appendMarkup' => '</div>' ); $redirectUri = str_lreplace('//', '/', $config->urls->httpRoot . $page->url); $content = $modules->get('Oauth2Login')->config( array( 'redirect_uri' => $redirectUri, 'success_uri' => $page->url ) )->render($options); }

       
      Screenshot