9

For those coming here using Craft 3, it's now Craft::$app->getConfig()->general->devMode.


8

I think you want this: {% set success = craft.request.getPost('test') %} {% if success %}form was just submitted{% endif %} Pass a string to getPost()


7

It's as simple as if ( craft()->config->get( 'devMode' ) ) { //do stuff }


6

It's definitely possible, your HTML is just a little off... When dealing with a dropdown menu, the name attribute should be part of the select tag, not each individual option: <select name="message[model]"> <option value="——" selected="selected">Please select...</option> <option value="volvo">Volvo</option> <option ...


6

To answer your questions in regards to how they will fit with Freeform... If what you mean by pre-populating fields with existing data is being able to fill fields with data from other elements, Freeform can do this. It allows you to populate fields with data from other Craft Elements or even common Predefined data included with Freeform such as States, ...


5

If you want the error messages to be displayed identical to P&T's template/macro default, this should do the trick: $(function(){ $('#ajax-form').submit( function(ev) { // Prevent the form from actually submitting ev.preventDefault(); // Remove any existing error messages from previous attempts $(this).find( '....


5

If you just want to test if something is in POST, and don't care what it is, then this should work: {% set success = craft.request.getPost() | length %} {% if success %} form was just submitted {% endif %}


4

I ended up hacking the ContactFormService.php file with some extra code for the body It's actually quite simple: $email->body = "Sender: ".$message->fromName."\n\nEmail-addreas: ".$message->fromEmail."\n\nMessage: ".$message->message; Same thing for cc mail I understood 2.2 will have a plugin hook for this kind of added functionality (emails.onBeforeSend ...


4

Make your own little plugin that listens to the plugin's contactForm.beforeSend event and sends the confirmation mail.


4

Apparently someone made a plugin that's doing exactly that https://straightupcraft.com/craft-plugins/contact-form-receipts


4

Anywhere you've currently got something that looks like this: {% if message is defined %}{{ errorList(message.getErrors('fromEmail')) }}{% endif %} Try changing that to: {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }} And you'll want to do that for the other attributes, too ('fromName', etc.).


4

You can see in the code for the plugin on GitHub that it sets a 'notice': craft()->userSession->setNotice($settings->successFlashMessage); As the official documentation mentions, this can later be grabbed with the following code: {% set message = craft.session.getFlash('notice') %} Then used as a normal message thereafter. {{ message }}


3

No. It's currently not possible, but you could make this a feature request! If you don't have the time, you could fork the plugin and make the changes yourself.


3

Well, the problem was that I was posting my Ajax request to / from all languages, therefore the site replied back with the site main language, which was French in my case. The following finally works: // Get the proper url to post to if ( '{{ craft.i18n.getCurrentLocale() }}' == '{{ craft.i18n.getPrimarySiteLocale() }}' { var url = '/'; } else { ...


3

I just came across this question, for the sake of up to date info for others, it is now possible to do this with the latest release(1.7) of the ContactForm plugin from Pixel & Tonic: https://github.com/pixelandtonic/ContactForm <input id="fromCompany" type="text" name="message[fromCompany]" value="{% if message is defined %}{{ message.messageFields.['...


3

There's no clean way doing this without making changes to the plugin itself. The contactForm.beforeSend event makes it possible to prevent the email from being sent from another plugin, but you're only being passed the compiled email message as a string. It's probably possible to post you checkbox data with that string and parse for it in your event ...


3

I figured out what was happening. There was a conflict with a previously installed plugin, Sprout Invisible Captcha.


3

A custom dropdown that allows you to trigger emails to different departments is possible using Sprout Forms and the Sprout Fields Email Select field.


3

The problem is the ... in your contactform.php file. The docs use it because they assume you might have some other valid config settings you want to include in that config file, but it's not real code, which is why PHP is choking on it. Remove the ... and you should be set.


3

I have it working now using this: $('#Form').submit(function(ev) { // Prevent the form from actually submitting ev.preventDefault(); var formData = new FormData($(this)[0]); // Send it to the server $.ajax('/', { url: '/', data: formData, type: 'POST', async: false, cache: false, contentType: false, processData: false, success: ...


3

There's a good article here for troubleshooting email errors and well as email deliverability issues: https://craftcms.com/support/troubleshooting-email-errors TL/DR: Don't use PHP's mail/sendmail methods in production and even in development, you aren't guaranteed email deliverability with those.


3

But, is it possible to do this when there is another contact form on the site? Yes? If so, what do I need to add to the department dropdown code? The dropdown code shouldn't have anything to do with it, if I'm following you correctly. Both forms just need to have a toEmail hidden input as specified in the docs: https://github.com/pixelandtonic/...


3

From the changelog: 1.7.0 Added the ability to access individual message fields values via message.messageFields when a validation error occurred. For example, the value of the input message[Phone] can now be accessed via message.messageFields['Phone']. So I think you should be using message.messageFields[Course] rather than message.message[Course]


3

There are several anti-SPAM form plugins available for Craft that should work for you (including a Google reCAPTCHA one).


3

I work with Sprout and can answer your questions with regards to Sprout Forms. 1. It should be possible to prepopulate fields with existing data This will happen by default in a lot of standard use cases when you are using Form Templates and when validation fails, for example. It's also possible to populate a Form Entry dynamically using the setEntry ...


2

Your options are either: 1) Hack the plugin to get it to add name and email to the body. 2) Use a more robust form-building plugin. 3) Use JavaScript to add a hidden input to the page that will add it to the body so they don't have to enter an email twice. Something like: <input id="emailCopy" type="hidden" name="message[emailCopy]" value="my@email....


2

In Craft 2.5 with Contact Form 1.4 I'm receiving the same error when using: {% if message is defined %}{{ message.contactTel }}{% endif %} I've gotten around this by using the Craft Request method getPost which can return a post value from an array. In the case of the original question, the following should work: <label for="fromCompany">Company:<...


2

There may be a better answer, or one forthcoming, but why don't you try using translation files? Note that the translations in the file can be any phrase, not just single words, so should fit well here. Craft doc on translation files I suspect this will work simply if you add the | t within the errorList macro at the to of the example contact form: ...


2

You could also hand this over to HTML since it supports form validation as of version 5. Depends on your browser support requirements though. This is what “Can i use” says.


2

It's relatively simple to tweak the Contact Form plugin to change the required fields. If you open models/ContactFormModel.php (in the plugin's folder), you can add 'required' => true, to the fromName attribute definition: 'fromName' => array(AttributeType::String, 'required' => true, 'label' => 'Your Name'), I tried this out, and it seemed ...


Only top voted, non community-wiki answers of a minimum length are eligible