Git Product home page Git Product logo

twigbundle-form's Introduction

Form helpers โ€“ TWIG

This Twig Bundle allows to reuse some helpful Form elements ... as Twig Macros.

WARNING: as always when working with forms ... the view isn't the (only) place to verify if a user is allowed to send specific information ... if you disable a form element or make it read only in the view, you also want to prove the data sent does not contain that specific value changed!

Data structures

As always, a template is using a dedicated data structure to be transferred into a view ... So the following section is on how the data has to be structured for the usage of the provided macros:

Form

The form macro is using a Bootstrap-DIV-based layout and can be adapted easily. To use it, you'll want to require the \macwinnie\TwigbundleForm\FormExtension class as Twig extension:

Form Element

By default, if none of the following options is selected, we'll get a <input> field rendered by this macro. If

Example usage

This is an example of a Twig template on how to build forms and a single form element:

<h3>Form-Testing</h3>

{% set form_data = {
    "create":
    {
        "action": "/tests/helper/?"
    },
    "buttons":
    [
        {
            "text": "submit",
            "class": "btn btn-primary",
            "name": "submitbutton",
            "value": "submit_val"
        }
    ],
    "rows":
    [
        {
            "name": "text",
            "placeholder": "ph text",
            "type": "text",
            "title": "single line textfield"
        }
    ]
} %}

{% import "form.twig" as forms %}
{% import "formelement.twig" as formelement %}

{{ forms.create( form_data ) }}

<hr/>

{{ formelement.create( form_data.rows[0] ) }}

twigbundle-form's People

Contributors

macwinnie avatar

Watchers

 avatar  avatar

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.