Giter Site home page Giter Site logo

roundhouse / formbuilder-2-craft-cms Goto Github PK

View Code? Open in Web Editor NEW
113.0 10.0 17.0 784 KB

FormBuilder 2 is a Craft CMS plugin that lets you create forms for your front-end. Now more slicker!

PHP 26.97% CoffeeScript 7.32% CSS 18.57% JavaScript 9.19% HTML 37.94%

formbuilder-2-craft-cms's Introduction

New Form Builder is coming!

Checkout current beta at https://formbuilder.tools/

Mou icon


FormBuilder 2 is a Craft CMS plugin that lets you create & manage forms for your front-end. Entries get stored to database so you can easily view your submission or export them.


Front-End Template Usage

Take a look at sampleForm.twig for required code. You will need to copy everything in that file and paste it to where you want to display your form.


Spam Protection

There are 2 options for spam protection, Time Submissions and Honeypot method.

1. Time Submission

Time submission will prevent spam bots for submitting the form too quickly. You need to enter a time (seconds) it should take a real person to submit a form. Typically 3 seconds is good enough.

2. Honeypot Method

With honeypot there is a hidden field that should be left blank. When spam bots run through the form they tend to fill out all the fields. If the honeypot field will get field the submission will fail. Real people will not be able to fill out this field so the form will submit successfully.


File Uploads

Create an Asset field and add it to your form. You need to select Has File Uploads box when creating your form to make sure files get submitted. If you have Email Notifications turned on, file uploads will be attached to the email.


Email Notifications

Templates have been added. Now you can visually set up email notification templates for admins or submitter. Currently with limited customization options but with feedback I'm sure we will add more. Check out this video for quick overlook.


Creating Forms

Hit Create New Form to create a new form.

  • Form Settings
    • Form Name - Give your form a name
    • Handle - Will be autogenerated, you can change to a custom one
    • Use Custom Redirect - Select this option if you want a custom redirect page (thank-you page). Redirect URL is required and is relative to your domain.
    • Has File Uploads - Select this if your form has file uploads
    • Use AJAX - Select this if you want your form to submit using javascript without page refresh. Note: You can't use Has Form Uploads and Ajax together yet (working on it).
  • Spam Protection
    • Timed Submissions - Select this and set time in seconds. Timed submissions will prevent quick spam robots from submitting too quickly.
    • Honeypot - Select this option to try and catch spam robots using a honeypot method. Hidden field in the form needs to be left empty, if filled the form will fail (most robots will fill this field).
  • Messages
    • Success Message - Enter form success message. If you form has custom redirect this is useless.
    • Error Message - Enter generic error message if submission has errors this will be displayed along with the field specific error message (Ex: Your Name cannot be empty).
  • Email Notifications
    • Notify Admin of Submission - Select this if you want to send email notification of submission.
    • Notification Email - Enter email where the notification should be sent to. you can enter multiple emails separated by a comma ,
    • Email Subject - Enter subject line for email notification
    • Include Submission Data - You can tick this option if you like the email to contain the submission content.
    • Email Template - You can pick if you want email to be Text Only or HTML Template.
    • Text Only - With this option you can enter optional Body Copy and Footer Copy.
    • HTML Template - With this option you can upload a custom logo, give email template a custom background color, give a container width as well as optional Body Copy and Footer Copy.
  • Fields
    • Add Fieldset Tab - Click this to add a fieldset. Then drag and drop fields into those fieldsets. You can also drag predefined fieldsets with fields form the Unused Fields section. If you don't see any fields you will need to head over to admin/settings/fields to create some fields.

Supported Fields

Here's a list of currently supported fields. Unlike FormBuilder there are no more custom fieldtypes, you only need to use Craft's predefined fields.

  • Plain Text
  • Checkboxes
  • Radio Buttons
  • Dropdowns (Select Options)
  • Multi Select
  • RichText (WYSIWYG)
  • Light Switch (Toggle)
  • Color (Color Picker)
  • Date
  • Number
  • Assets (Only local file uploads supported for now, no s3, no rackspace)

Custom Fields HTML Markup

If you want to have custom markup for your rendered fields follow these steps to achieve it.

  • While editing your form go to the Fields tab.
  • Click the settings icon next your field and hit Custom Template option.
  • Enter your template path located in craft/templates.
  • Example: enter forms/text, place text.html or text.twig into craft/templates/forms/

Custom Redirects

You can pass submission data to a custom redirect page, here is a snipped code for getting started.


{% set submissionId = craft.request.getCookie('formBuilder2SubmissionId') %}
{% set submission = null %}
{% if submissionId %}
  {% set submission = craft.formBuilder2.getFormById(submissionId.value) %}
{% endif %}

{% if submission %}
  {{ submission.form |inspect }}
  {{ submission.data |inspect }}
{% endif %}

  • First we are getting a submission ID by checking cookies for it.
  • If we get an ID we call a function to get the submission
  • When and if you get a submission back you can use submission.form to get form information and submission.data to get submission information
    • submission.form.id - Form ID
    • submission.form.title - Form Name
    • submission.data - Holds submission data...so if your form had a field with handle name yourEmail you can call submission.data.yourEmail to get your string.

Ajax Submission Event

You can use a custom formbuilder2:submit event to check for ajax submissions:

document.addEventListener("formbuilder:submit", formBuilderSubmission, false);
function formBuilderSubmission(e) {
	var details = e.details;
	var response = e.detail.response;
   	var success = e.detail.response.success;
}

For example, if you want to track successful submissions you can:

document.addEventListener("formbuilder:submit", successfulSubmission, false);
function successfulSubmission(e) {
   	var success = e.detail.response.success;
   	if (success) {
   		// add your tracking code here
   	}
}

Form's Terms & Conditions

You can now add "Terms & Conditions" to your forms. In your form settings, there is a new tab called Extra. You will need to update your front-end code to use this functionality. Add the following to your code right above the notifications div. You can also checkout the sampleForm.twig file for examples.

{% if form.extra['termsAndConditions'] is defined and form.extra['termsAndConditions'] %}
  {{ craft.formBuilder2.getTermsInputs(form) |raw }}
{% endif %}

Todo

  • Exporting entries
  • Update documentations
  • Visual data reporting

Changelog

Refer to releases.json for updates.

Issue Tracking and Bug Reporting

If you have found a bug or would like to request a feature please use Github's Issues to report and track issues.

License

The MIT License (MIT)

Copyright (c) 2014 Roundhouse Agency Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

formbuilder-2-craft-cms's People

Contributors

adamdburton avatar carlosperez avatar davidwickman avatar dubcanada avatar hambrook avatar jbueler avatar jimmylorunning avatar lauramontgomery avatar macxim avatar mtnorthrop avatar nullvariable avatar owldesign avatar tiborsaas avatar vadim-rh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

formbuilder-2-craft-cms's Issues

Validation of textarea

I have a textarea on my form, and it is "required". When I submit it without filling it in, it won't let me, but it also won't pop up the notification that that is what's wrong.

When I do the same with an input text field, I get a very helpful message "please fill out this field".

Is this a bug?

Get Form by ID instead of Handle

I was wondering how I could get a form object with an ID. The getFormById function behaves differently than the getFormByHandle. What I'm trying to do is have a user pick an existing form within an entry. Unfortunately right now, the only data I get is the ID of the form. If getFormById returned $form it would work fine. Thoughts?

/**
     * Get Form By Id
     * 
     */
    public function getFormById($formId)
    {
        $form = craft()->formBuilder2_form->getFormById($formId);

        $variables['formId'] = $form;

        craft()->path->setTemplatesPath(craft()->path->getPluginsPath().'formbuilder2/templates');
        $html = craft()->templates->render('/forms/frontend', $variables);
        craft()->path->setTemplatesPath(craft()->path->getTemplatesPath());

    return $html;
    }

    /**
     * Get Form By Handle
     * 
     */
    public function getFormByHandle($formHandle)
  {
    return craft()->formBuilder2_form->getFormByHandle($formHandle);
  }```

Configuration Blank Page

After installing the plugin successfully FormBuilder2 is is appearing in the sidebar as well as on the settings page and in the plugins as installed and active. Unfortunately, I'm getting a completely blank page when I try to load the configuration or click on any links associated with FormBuilder2. Would you happen to have any ideas on how to address this?

email notification based on html select/dropdown value

I have a form that contains a select/dropdown field with a few different options. I would like the form submission notification to be sent to a different email based on what option is selected in the field. Is this possible with FormBuilder?

Can't select custom logo when attempting HTML template option

Hi Again,

Just tried to select a logo within the HTML template area on a form.

It loads up the assets window, I can see all my asset sources though the files that definitely exist (I can see them in the asset manager) are not visible within this window. This is both the same for local asset sources & S3 asset sources.

The plugin
image

My asset manager (photoshopped the thumbnails out for a bit on anonymity, it's not broken):
image

Error when using Ajax

When I activate AJAX for a form, and submit it in the front end (using an unaltered example form code), I get this error message:

The request could not be understood by the server due to malformed syntax.

The form works perfectly without AJAX.

Worth mentioning I'm on Craft 2.4.2693 and testing locally on a Mamp server.

Variable "id" does not exist for checkboxes

When using checkboxes as a field for a form I get the following template error on the front-end

I'm using craft25 branch of FormBuilder 2 and Craft Client 2.5.2720

Variable "id" does not exist

/craft/plugins/formbuilder2/templates/inputs/checkbox.twig(9)

<label{% if required is defined and required %} class="required"{% endif %}{% if id %} for="{{ id }}"{% endif %}>

input text type

Hi Guys,

Noticed that the "type" attribute for a text field is incorrect. textarea/file fields appear fine, maybe it's just this one? Maybe the class/type fields are the wrong way around for this one?

image

Link to the file uploaded broken on the email notification

Hi! Thanks for the plugin!

Have you noticed that if you upload a file with the form, you'll get an email notification with a section called "File Uploads" but the link to the file uploaded goes to "uploads/" which means we get a 404.

Also, the file name should probably be modified so that special characters don't break the link. For example, if the file name uploaded includes dashes or spaces, the file name will break.

File uploads should respect dynamic upload locations set in asset fields

Awesome plugin. Thanks a bunch.

This is probably a feature request, but it is an issue that is causing me problems with how the uploaded files are being organized.

When uploading a file, dynamic file locations should be respected as configured in the asset field settings. Additionally an option to either replace existing files or renaming uploaded files should be added to the form options.

Typo on Wiki

There is a typo in the wiki; 'enought' when it should be enough on the following line:

'Typically 3 seconds is good enought'

Required Checkboxes: won't let you submit unless the FIRST item of a series of checkboxes are checked

I'm not sure what it means to have a checkboxes field be "required". But when I put it on a page and hit submit, it said I can't submit it until I check the box. But I had checked some boxes, just not the first one in the field. Apparently, unless the first box is checked, it considers it empty.

However, I think the ideal behavior would be if ANY of the boxes are checked, then it considers it filled. If NONE of the boxes are checked, AND it is a required field, it should give an error. That's just what my understanding would be. But some may argue that none of the checkboxes being checked is also a way of answering the question. So maybe in that case "required" doesn't hold any meaning at all.

How can I pass value to the input on the frontend?

Hi,

I've seen that you can pass an array for a value to getInputHtml: public function getInputHtml($field, $value = []) how would I write this on the front end? Twig is a bastard with arrays right so you have to pass it a "hash"?

Having no luck with: {% set input = craft.formBuilder2.getInputHtml(field, {"value":craft.request.url}) %}

Any ideas on what I can do to accomplish that?

Cheers

Ability for admins/other dashboard users to change the notification email sent from name

Hi,

I believe this is a feature request, but if it's possible another way please enlighten me!

I would like the ability for a craft user to update the form's name, for example, it may make more sense in the backend for a form to be called "Services Sidebar Contact Form", but, doing so would also set that as the sender name in notification emails to the submitter (if using notify submitter).

I would like to have a form name that makes sense to the dashboard user, but, another that can be altered to make sense for the public too.

tl;dr - I would like a new field for the public form name.

image

Templates Path screwed up once again

I fixed this bug before, but it seems like it's back. After pulling in the form, if I then try to include a file, it won't find it because it's looking for it in the plugins path. I can fix this again if you want me to, let me know.

When activated, I am unable to add / edit Craft fields locally.

I noticed that when the "Form Builder 2" plugin is activated, I am unable to create a new field or edit any existing fields without there being a 500 Internal Server Error. I trouble shot this to better understand if it is the plugin or the way my environment is configured. I discovered that this problem goes away once the "Form Builder 2" plugin is disabled. However, I tried your first "Form Builder" and learned it does not create this error. I wanted to make you aware of this and look forward to using the new "Form Builder 2" in the future. Let me know if this is confusing or if you have any follow up questions.

Pass additional parameters to email

Hi, thanks for the great plugin!

Is there a way to send additional parameters to the email. Eg. by using hidden fields in the form?

I'm using the form for landing pages and I need to show which page the form was filled and sent from eg. by showing the url path as part of the form data in the email notification sent.

Thanks in advance
Daniel

redirect to same page as form but with query string

I would like to be able to redirect after a form submission to: {{ craft.request.url }}?message=thankyou which despite being hardcoded in the form like this:

<input type="hidden" name="formRedirect" data-custom-redirect="{{ formSettings.formRedirect.customRedirect }}" value="{{ craft.request.url }}?message=thankyou"> 

It still redirects to /?message=thankyou even if you are on an alternative page such as /about.
I have tried setting ?message=thankyou in the backend too, and, using the original code, though the behaviour is the same as hardcoding it.

500 Server Error

I was developing locally on my machine using AMPPS, and the plugin worked well. I then moved my site to a server, and was getting the issue of the plugin not showing up in the plugins list. I figured out I needed to make the name of the plugin folder all lowercase. After doing that the plugin showed up and I installed it. However, when clicking on the FormBuilder2 link to set up a new form, edit configuration, etc, it is taking me to a page with a 500 Server Error (the url is http://domain.com/admin/formbuilder2/tools/configuration)

I did disable/enable, uninstall/re-install, but those didn't make a difference.

Any tips for troubleshooting this? I am on the latest version of Craft (Craft Client 2.5.2767)

Custom HTML for form

I am needing custom HTML for my form that just looping through the fields doesn't allow me to do. Is there a way to call a singular form input?

I don't see anything in the documentation on how to do it.

Create a multi-page form

I am trying to create a multi-page form.
On the first page, the customer can fill in all his required entries. Then the form should be passed to a new page where the customer fills in all of his personal information. Is it possible to do this or should it be done using javascript to show a particular part once the other part is finished?

Undefined variable: path

PHP Notice says the following:

public function getTemplatesPath()
    {
        craft()->deprecator->log('PathService::getTemplatesPath()', 'PathService::getTemplatesPath() has been deprecated. Use TemplatesService::getTemplatesPath() or TemplatesService::getTemplateMode() instead.');
        return craft()->templates->getTemplatesPath($path);
    }

Craft CMS 2.6.2778

Version

Just a quick note to say that the version number hasn't been updated for the latest release.

Feat: Pass form params to thank you page

Hi, I was wondering what you thought of passing the form data to the thank you page. Sometimes, you might want to customize that page accordingly. I also thought it might be cool to integrate with other plugins like a mailchimp one, so for now I was going to have my redirect go to my mailchimp controller so I need the data. Maybe there is a better or easier way?

I was thinking in FormBuilder2_EntryController once the form validates (line 269), you can modify one line

$this->redirect(array($redirectUrl, 'submission_data'=>$submission));

Size attribute appears in markup even if empty

Just doing some w3c validation:
image

for:
<input type="text" class="text" id="text-2101002558" size="" name="formName" value="" required placeholder="" autocomplete="off">

It's moaning as the size attribute is empty. I notice in your text input template:
{%- if max is defined %} size="{{ max }}"{% endif %}

I've changed this to

{%- if max is defined and max|length > 0 %} size="{{ max }}"{% endif %}

Plugin Not Showing when Uploaded at server

I was working on my localhost enviroment and everything works fine until I've uploaded the whole project on the final server.

In this final server the plugin it's not appearing on plugin section.

I've uploaded every file on craft/plugins but It is not showing on dashboard.

What could be happening?

Thanks in advance.

Couple of queries - user email notification, validation, etc

I know this is a new one, i have just seen, so just general queries.

1 - typically the user entering the form, and the admin would receive a email notification. is this currently possible? i.e. different messages for user from admin

2 - validation of required and data entered - i see required, but is there more than this? Is the validation done using HTML 5, JS, or server side?

3 - export - can i export forms seperately, or only all at once?
And a side issue - do you use Yii / crafts object model for creating the download as with most other form plugins? if so this destroys memory, and PHP timeouts and usually prevent exports from working on large amount of entries!!!

Background colour missing from Plugin admin page

The dark grey is missing from your header in branch craft25 and using Craft Client 2.5.2720

Or alternatively you could say the FormBuilder logo needs a darker colour :)

Tested in FF 42.0 , Chrome 46 and Safari 0.0.1

Dropdown fields are not coming through when submitted

Create a form with a dropdown on it. Put it on a page template. Fill out the form and submit it. Look at submitted entries, and you will see that the dropdown value was not sent.

And if you made it a required field, it won't let you submit the form at all, even if you have selected a value from the drop down.

Field type not updated when adding new form

I’m testing FB2 on Craft 2.5.2755 with PHP7. When using the Forms field type, the list of forms that appear in the drop down doesn’t update when I add new forms. It shows only the forms that were already there when I created the field.

Am I missing something?

Create a Form button/link?

After creating one form I can't seem to find a link or button to create another form. Assumed it would be on the Forms tab but I'm not seeing it. Using Craft 2.5 and FB2 0.1.

The screenshot shows a Quick Link for Create New Form but my screen doesn't look like the one in the screenshot.

Thanks.

formbuilder

Undefined options when adding Form to Matrix Field

To replicate, create a new Matrix field and add a Form to one of the nodes. Save the Matrix field and add to a section. In the Admin side, try create a new entry for that section. you get a php error

undefined index: options

In the FormBuilder2FieldType.php, checking for options if they are set would fix this.

/**
     * @inheritDoc IFieldType::getInputHtml()
     *
     * @param string $name
     * @param mixed  $value
     *
     * @return string
     */
    public function getInputHtml($name, $value)
    {
        $field = craft()->fields->getFieldByHandle($name);

        return craft()->templates->render('formbuilder2/fieldtypes/forms/html', array(
            'name'    => $name,
            'value'   => $value,
            'options' => $field->settings['options']            
        ));
    }

Get Undefined index: notifySubmitter

Hi,
Thank you for bringing this amazing plugin to version 2.
I tried to create a new form after installing
however I get Undefined index: notifySubmitter error on saving the form

/vagrant/craft/plugins/formbuilder2/services/FormBuilder2_FormService.php(157)

145     if ($spamProtectionSettings['spamHoneypotMethod'] != '' && $spamProtectionSettings['spamHoneypotMethodMessage'] == '') {
146       $form->addError('spamHoneypotMethodMessage', Craft::t('Please enter message for screen readers.'));
147     }
148     
149     if ($notificationSettings['notifySubmission'] == '1' && $notificationSettings['emailSettings']['notifyEmail'] == '') {
150       $form->addError('notifyEmail', Craft::t('Please enter notification email.'));
151     }
152 
153     if ($notificationSettings['notifySubmission'] == '1' && $notificationSettings['emailSettings']['emailSubject'] == '') {
154       $form->addError('emailSubject', Craft::t('Please enter notification email subject.'));
155     }
156 
157     if ($notificationSettings['notifySubmitter'] == '1' && $notificationSettings['submitterEmail'] == '') {
158       $form->addError('submitterEmail', Craft::t('Please select email field.'));
159     }
160     
161     $formRecord->validate();
162     $form->addErrors($formRecord->getErrors());
163 
164     if (!$form->hasErrors()) {
165       $transaction = craft()->db->getCurrentTransaction() === null ? craft()->db->beginTransaction() : null;
166       try {
167         if (!$isNewForm && $oldForm->fieldLayoutId) {
168           craft()->fields->deleteLayoutById($oldForm->fieldLayoutId);
169         }

I'm using Craft CMS 2.6.2776
Hope you have a better idea on what's happened.

Thank you!

Email Address Field type custom input

Hi Vadmin,

Thanks so much for your plugin, it's ace, just been trying it out and it doesn't look like there's any option for a custom field type?

For example: I want a field for "Email" but a custom field that has been added by myself or say "Sprout Fields" does not get picked up.

All I want to do is change the input "type" attribute to "email" so my custom validation.js can validate email addresses.

Can you suggest a way of doing this?

Thanks

HTML template for "notify submitter" notification email

As a feature request (if you are not already planning to do this) I would love to have the same template options to make it look better for submitter notifications just like you have setup for the admin notifications.

The notification emails are a bit underwhelming at the current time:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.