Code Monkey home page Code Monkey logo

mambo-forms's Introduction

mambo-forms

#Form renderer With the template helper {{> renderForm formOptions}} you can render a form.

<template name="templateWithAForm">
  {{>renderForm formOptions}}
</template>

Template.templateWithAForm.helpers({
  formOptions: ->
    title: 'A h1 Title for the form'
    formHint:
      alertType: 'warning'
      text: 'Something'
    formFields: [
      ...
    ]
    actions: [
      ...
    ]
})

#Render single form element

<template name="someTemplate">
    {{#with inputOptions}}
    {{> input}}
    {{/with}}
</template>

Template.someTemplate.helpers {
    inputOptions: ->
        label: 'Some Label'
        formHint: 'Some hint'
        inputName: 'nameOfInput'
        type: 'text'
        placeholder: 'Write something'
}

#Field Errors

Errors for fields are automatically shown if they are in the Session-Variable called 'formErrors'. Simply use the name of the input field as the key and the error message as the value.

Session.get('formErrors')
->
{
    "email": "This is not a valid email",
    "street": "Please enter a valid street name"
}

In order to remove all Form errors use

Form.removeFormError()

Remove only one form error

Form.removeFormError('email')

#Form Fields

You can see all available fields in the forms.html file

###Input

{{>input}}

label: String
formHint: String
inputName: String
type: String
placeholder: String

##Textarea

{{>textarea}}

label: String
inputName: String
placeholder: String

##Select

{{>select}}

label: Optional String
inputName: String
options: Array [{key: String, selected: Boolean, label: String, attributes: String}]

##TODO other fields

mambo-forms's People

Contributors

manuel-schoebel avatar

Stargazers

 avatar  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.