Code Monkey home page Code Monkey logo

contactbundle's Introduction

ContactBundle

Bundle of Symfony for create contact forms

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require vzenix/ContactBundle "~1"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new VZenix\Bundle\ContactBundle\ContactBundle()
        );

        // ...
    }

    // ...
}

Step 3: Create structure in database

php bin/console doctrine:schema:update --force

Step 4: set configuration in config.yml

# Contact page configuration
contact:
    
    # Configuration for mailing form (require swiftmailer=true)
    mail:
        subject: "Subject for mail"
        to: "<your email>"
        from: "your email"

    # templates to use in website and mailing
    templates:
        view: "default/contact.html.twig"
        mails: "emails/contact.html.twig"
        
    # Time in second betwen post request
    lapsus: "2"
    
    # Set true for log the form in database
    log: true
    
    # If you want a mail when form is send
    swiftmailer: true

Step 5: Personalize web template

    <!-- Main -->
    <div id="main" class="wrapper style1">

        <div class="container">
            <header class="major" id="messages_zone">
                <h2>Form contact</h2>
                <p>Lorem.</p>
            </header>

            <section class="error-form fade{% if messages_error != true %} hide{% endif %}">
                Ups, cannot send the form, review field and try again
            </section>

            <section class="ok-form fade{% if messages_sent != true %} hide{% endif %}">
                All is ok.
            </section>

            <!-- Form -->
            <section>

                <h3>Lorem.</h3>

                <form method="post" action="#">
                    <div class="row uniform 50%">
                        <div class="6u 12u$(xsmall)">
                            <input type="text" name="name" id="name" value="{{autocomplete.name}}" placeholder="Name" />
                        </div>
                        <div class="6u$ 12u$(xsmall)">
                            <input type="email" name="email" id="email" value="{{autocomplete.email}}" placeholder="Email" />
                        </div>
                        <div class="12u$">
                            <input type="text" name="calculator" id="calculator" value="" placeholder="Type the result of {{robot}} = ?" />
                        </div>
                        <div class="12u$">
                            <textarea name="message" id="message" placeholder="Your message" rows="6">{{autocomplete.message}}</textarea>
                        </div>
                        <div class="12u$">
                            <ul class="actions">
                                <li><input type="submit" value="Send message" class="special" /></li>
                                <li><input type="reset" value="Reset" /></li>
                            </ul>
                        </div>
                    </div>
                </form>
            </section>

        </div>
    </div>

Step 6: Personalize mailing template

<p>You have a message from your web</p>
<p>Name: {{name}}</p>
<p>Email: {{email}}</p>
<p>Message: {{message}}</p>

contactbundle's People

Contributors

vzenix avatar

Watchers

 avatar  avatar

contactbundle's Issues

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.