0.05
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
This is a Rails Engine for https://github.com/dobtco/formbuilder.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.2.1, ~> 2.2
>= 0.7.0, ~> 0.7
>= 1.2.0, ~> 1.2
>= 4.4.1, ~> 4.4
>= 4.2.8, ~> 4.2
>= 2.4.2, ~> 2.4
>= 2.14.1, ~> 2.14
>= 1.1.2, ~> 1.1
>= 1.0.1, ~> 1.0
>= 1.5.3, ~> 1.5
>= 1.6.2, ~> 1.6

Runtime

>= 0.10.0, ~> 0.10
>= 0.1.0, ~> 0.1
>= 1.1.9, ~> 1.1
>= 0.17.1, ~> 0.17
>= 4.0.0, ~> 4.0
>= 1.7.3, ~> 1.7
>= 2.13.2, ~> 2.13
 Project Readme

Alert: This gem is used internally at DOBT, and might not be perfect for your implementation. We recommend forking this repository and using it as a starting point. It's hard to gem-ify this stuff without integrating it into your app completely.

Formbuilder.rb circle ci status Coverage Status

Formbuilder.rb is a Rails Engine that's designed as a compliment to Formbuilder.js, a library that lets your users create their own webforms inside of your application.

Since Formbuilder.rb is a fairly non-trial piece of software, it's important to understand its components and how it works:

  1. We add ResponseField, EntryAttachment, and Form models to your application. (Each type of response field (text, checkboxes, dropdown, etc.) uses STI, inheriting from the ResponseField model.)
  2. You include Formbuilder::Entry in an existing model.
  3. We add a few classes to help you render forms and entries.

Note: All Formbuilder models and classes are namespaced within the Formbuilder module.

If you have a few moments, consider reading the source, especially the Rails app in spec/dummy, as it should give you a good idea of how Formbuilder integrates.

Requirements

Postgres is currently required. See Issue #1.

Carrierwave and Rmagick for file uploads. Geocoder to geocode address fields.

Installation

1) In your Gemfile

gem 'formbuilder-rb', require: 'formbuilder'

2) Create the migrations for the Formbuilder models

  1. rake formbuilder:install:migrations
  2. rake db:migrate

3) The Entry model gets mixed in to an existing model in your application

#  responses       :hstore
#  responses_text  :text

class Entry < ActiveRecord::Base
  include Formbuilder::Entry
end

4) Associate a form with an existing model (optional)

class MovieTheater < ActiveRecord::Base
  has_one :form, as: :formable, class_name: 'Formbuilder::Form'
end

Usage

Render a form

<%= Formbuilder::FormRenderer.new(@form, @entry).to_html %>

Save an entry

@entry = Entry.new(form: @form)
@entry.save_responses(params[:response_fields], @form.response_fields) # validates automatically

Validate an entry

@entry.valid?
# => false

@entry.error_for(form.response_fields.first)
# => "can't be blank"

Integrate with the Formbuilder.js frontend

# config/routes.rb
resources :forms, only: [:update]

# app/controllers/forms_controller.rb
class FormsController < ApplicationController
  include Formbuilder::Concerns::FormsController
end

License

MIT