Jump to content

Simple Contact Form


justb3a

Recommended Posts

Since I haven't received answers, I add the code directly in the module (I know is bad but I need to finish)
Line 264:

$inputfield->attr('class','form-control');

It would be great if this option was in the configuration as well as the current option for the Send button

Link to comment
Share on other sites

  • 2 weeks later...
On 28/06/2017 at 9:53 PM, Pixrael said:

Since I haven't received answers, I add the code directly in the module (I know is bad but I need to finish)
Line 264:


$inputfield->attr('class','form-control');

It would be great if this option was in the configuration as well as the current option for the Send button

Hi, I spent the last days without a computer (holidays!!) so I didn't read my emails :)
But the forum offers a lot of good advice and you're not the first one who asking this. So please have a look at the following posts / answers:

Link to comment
Share on other sites

1 hour ago, Pixrael said:

I like the second solution, I will implement it later. Thank you!

It works, but applies the classes to all inputfields, including the form and buttons. Is there any way to ask the type of input (Ex. InputfieldText) before applying the classes? I check the API Reference for inputfield but nothing..

Link to comment
Share on other sites

I just tried to install it a few times on the current release version, but I get this same error every time:

Error: Uncaught Error: [] operator not supported for strings in /Users/me/git/site.net/site/modules/SimpleContactForm/SimpleContactForm.module:131
Stack trace:
#0 /Users/me/git/site.net/wire/core/Modules.php(602): ProcessWire\SimpleContactForm->init()
#1 /Users/me/git/site.net/wire/core/Modules.php(477): ProcessWire\Modules->initModule(Object(ProcessWire\SimpleContactForm))
#2 /Users/me/git/site.net/wire/core/ProcessWire.php(495): ProcessWire\Modules->triggerInit()
#3 /Users/me/git/site.net/wire/core/Wire.php(380): ProcessWire\ProcessWire->___init()
#4 /Users/me/git/site.net/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___init', Array)
#5 /Users/me/git/site.net/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessWire), 'init', Array)
#6 /Users/me/git/site.net/wire/core/ProcessWire.php(587) (line 131 of /Users/me/git/site.net/site/modules/SimpleContactForm/SimpleContactForm.module) 

This error message was shown because: you are logged in as a Superuser. Error has been logged.

 

Link to comment
Share on other sites

3 hours ago, Claus said:

I’m on 7.1.5

So you either have to downgrade to PHP 7.0.x or wait for @justb3a to update the module. You can "hack it" too, either by actually changing the module's code or you can try the "multiple copies of the same module" technique:

https://processwire.com/blog/posts/processwire-core-updates-2.5.14/

I never did the latter, BTW.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I feel very stupid. I read all the thread and all the documentation. But I'm unable to hide scf-website by css. How I can add class='hidden' to this specific field?

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

						$options = array(
						 'btnClass' => 'button is-primary',
						 'successMessage'  => 'Message Sent!',
						 'errorMessage'  => 'Sorry - error, your message was not sent!',
						 
						  'markup' => array(
							'list' => "<div class='field' {attrs}>{out}</div>",
							'item_label' => "<label class='label' for='{for}'>{out}</label>",
							'item' => "<div class='control'>{out}</div>",
							'item_error' => "<article class='message is-warning'><div class='message-body'>{out}</div></article>",
						  ),
			
						);

						echo $scf->render($options);

Thanks

Melanie

Link to comment
Share on other sites

It's not that easy to access only this field, you could add a class for every "InputfieldText" for example.

But why not extending your CSS as @alexmercenary suggested? If you do not want to use an ID as CSS selector you could use classes as well.

This is the default markup:

<div class="form__item form__item--scf-website" id="wrap_Inputfield_scf-website">...</div>
<div class="form__item form__item--scf-date field--required" id="wrap_scf-date">...</div>

As you can see, every field gets wrapped using the class form__item--{fieldname}. Just extend your CSS:

.hidden, 
.form__item--scf-website {
    display: none;
    visibility: hidden;
}

:)

Link to comment
Share on other sites

  • 2 weeks later...
On 7/19/2017 at 7:16 AM, Claus said:

I just tried to install it a few times on the current release version, but I get this same error every time:

[...]

As a follow-up to this, where exacty is allFields first declared before init() is called? Not sure what's going on there, because that's supposed to be an array, but it looks like PHP is calling it a string...?

Link to comment
Share on other sites

  • 3 weeks later...

Uff, after a few weeks i have a problem with the checkboxes in the form.
They 're not required, but the user can't send the form when not checked.

Anyone with same problems?

Iam using two different forms on my website (different pages) which haven't the same fields,
i set the fields for the particular form with:

$options = array(
  'allFields' => 'sfc_tel,scf_fax,scf_email,scf_subject,scf_message,scf_haendlerwerden',
  ..
);

scf_haendlerwerden is a checkbox, not-required. 
Is that where the error comes from, selecting the fields via $options["allFields"] ?

ProcessWire 3.0.75

Link to comment
Share on other sites

On 21/09/2017 at 9:14 PM, maxf5 said:

Any ideas? How do you set up checkboxes?

Hei, I found some time to reproduce your issue. The logfile (BE > Logs > Simplecontactform-log) contains the reason what's going wrong:

> [FAILURE] Number of fields does not match.

This means that the number of submitted fields does not match the number of fields which are present in the form. Looking further it turned out that $this->input->post does not contain the checkbox field (if it wasn't checked). 

It's a standard browser behaviour that the value of a checkbox is only sent if the checkbox was checked. This means I have to exclude this fieldtype when comparing number of fields / counting fields. coming soon...

 

Edit: Just published a new release / version 1.0.5. Please update.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Hi justb3a, the module is amazing! I think I found a small glitch: if one tries to enter more than one field name in "Create and add fields" (comma separated), ProcessWire throws an error:

 ProcessWire: ProcessModule: Field name 'scf__contact_lastname' may not have double underscores because this usage is reserved by the core

Field names I tried with are like this: contact_title, contact_firstname, contact_lastname...
If this field names are entered in one by one, all is well.

PW version 3.0.76

Link to comment
Share on other sites

  • 1 month later...

@titanium The problem wasn't that you entered multiple fieldnames at once. The comma-separated may not include spaces. So entering `contact_title,contact_firstname,contact_lastname...` does work. I added a hotfix which removes the spaces before parsing the string.

Link to comment
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
×
×
  • Create New...