https://github.com/laertispappas/dynamic_form_objects
Create simple form objects
https://github.com/laertispappas/dynamic_form_objects
form-objects ruby
Last synced: about 2 months ago
JSON representation
Create simple form objects
- Host: GitHub
- URL: https://github.com/laertispappas/dynamic_form_objects
- Owner: laertispappas
- Created: 2016-07-24T20:54:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-24T20:55:59.000Z (almost 9 years ago)
- Last Synced: 2024-04-24T13:45:50.307Z (about 1 year ago)
- Topics: form-objects, ruby
- Language: Ruby
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DynamicFormObjects
Create Form Objects "on the "fly". Useful for defining simple forms.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'dynamic_form_objects'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install dynamic_form_objects
## Usage
Create a form object:
```ruby
UserForm = DynamicFormObjects.define_form('UserForm', :name, :age)
# Or add some validations:
UserForm = DynamicFormObjects.define_form('UserForm', :name, :age).with_validations do
validates_presence_of :name
# Other validations...
enddef new
@user = UserForm.new
enddef create
@user = UserForm.new(params[:user])
if @user.valid?
...
else
...
end
end```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dynamic_form_objects.