Giter VIP home page Giter VIP logo

hungryform's People

Contributors

andrba avatar seanhussey avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

seanhussey

hungryform's Issues

Js module

Create a js module for dependency handling and form navigation.

Default settings

It would be good to have some sort of form elements configuration, where we could set up default attributes.

Rather than doing this every time we define a new field in a form

text_field :first_name, max_length: 100
text_field :last_name, max_length: 100

we could configure it like this

HungryForm::Elements::TextField.configure do |c|
  c.max_length = 100
end

New elements

We need to create more elements:

  • text_area
  • radio_group
  • check_box
  • check_box_group

Route helpers

Currently it is required to define two routes to handle forms:

  get 'hungryform/:page' => 'hungryform#show'
  post 'hungryform/:page' => 'hungryform#update'

It would be worth creating some sort of a helper to define all form routes in one line.

Generation of multiple groups of the same structure

Sometimes it is necessary to create multiple groups of the same type. Imagine we have a form that asks about the addresses a person lived at within 10 years. Each address should consist of the following fields:

text_field :line_1
text_field :line_2
text_field :city
text_field country

Rather than copy-pasting 10..20 groups in the form definition we could set a quantity: 10 or multiple: true parameter which will render these groups automatically. Each group will have its number in the name, like page_mygroup_1 with field names like page_mygroup_1_city.

The question is how it will be rendered in the Rails app. Obviously we should not show to a user 10 groups all at once. I see two ways of doing it:

  1. Controlling dropdown
    Link group visibility to a dropdown with numbers 0..10. When a user selects the quantity of groups the corresponding amount of groups become visible.
  2. Add more / Delete buttons
    A group is rendered as a template that will be used by js to generate more groups. When a user clicks on "Add More" a new group is generated and becomes visible. Next to the group will be a button to delete this group.

Any other ideas are welcome!

Namespaced form field classes

It would be better to create a namespace for form fields. Currently they are all located under the HungryForm class, that has some other classes such as Validator or Resolver. A class lookup loops through these classes every time a new field is created.

Rendering HTML

A decision needs to be made to what extent this gem will be responsible for rendering HTML. If it is used extensively with frameworks like Rails or Sinatra, it will be better to delegate all this work to their template engines. However, this delegation will require extra work to be done each time it is used in a project.

Another option is to create a gem for each framework individually. If it is based on a current gem it can make integration easier.

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.