Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/langalex/forms-fu
enhanced form handling for rails applications
https://github.com/langalex/forms-fu
Last synced: about 1 month ago
JSON representation
enhanced form handling for rails applications
- Host: GitHub
- URL: https://github.com/langalex/forms-fu
- Owner: langalex
- License: mit
- Created: 2008-04-11T13:08:41.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2008-07-15T16:36:58.000Z (over 16 years ago)
- Last Synced: 2024-04-13T09:17:55.245Z (9 months ago)
- Language: Ruby
- Homepage: http://upstream-berlin.com/blog/open-source/#forms_fu
- Size: 78.1 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
Awesome Lists containing this project
README
forms-fu
======================this plugin is intended to help in creating forms. its featureset will grow in the near future. for now it can do this:
* adds a required_field?(field_name) method to all the activerecord models. this allows you to automatically mark required fields in a form with a *. required fields are determined automatically from the validates_* calls in the class.
* there is a helper method available in the views that prints out the label for a field with our without star
* a TabularForumBuilder class which can be used with the form_for rails helper. It automatically wraps all form fields in table rows and cells.
Examples
=======# user.rb
class User < ActiveRecord::Base
validates_presence_of :name
validates_confirmation_of :password
validates_acceptance_of :terms
required_fields << [:login] # in case you want to mark additional fields as required
endUser.required_field?(:name) # => true
User.required_field?(:login) # => true
User.required_field?(:password_confirmation) # => true
User.required_field?(:terms) # => true
User.required_field?(:email) # => false# users/new.html.erb
<%= label_fu @user, :name %> # => Name *
<%= label_fu @user, :email %> # => Email# or with the form builder
<%- form_for :user, :builder => TabularFormBuilder do |f| -%>
<%= f.text_field :name %>
<%- end -%># prints out:
Name: *
# some added sugar:
<%= f.text_fields :email, :name, :address %>
# call text_field for each of the attributes
<%= f.text_field_without_label :name %>
# prints out the input tag without the tr, td and label - in case you need more customization
For questions, patches etc. contact alex[at]upstream-berlin.com
Copyright (c) 2008 Alexander Lang, released under the MIT license