Permalink
Browse files

checkbox field used in the example app and helper in form_view

  • Loading branch information...
Chris Nelson
Chris Nelson committed Jun 5, 2012
1 parent b74477f commit 95e425e9e65bbb9be967d21869a9950675ebdaef
@@ -6,6 +6,7 @@
%fieldset
= @textField(field: "first_name", label: "First Name")
= @textField(field: "last_name", label: "Last Name")
+ = @checkBoxField(field: "evil", label: "Evil")
= @dateField(field: "birth_date", label: "Birth Date", format: "yyyy-mm-dd")
= @selectField(field: "occupation_id", label: "Occupation", collection: @occupations)
.modal-footer
@@ -0,0 +1,5 @@
+class AddEvilToPeople < ActiveRecord::Migration
+ def change
+ add_column :people, :evil, :boolean
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120526164853) do
+ActiveRecord::Schema.define(:version => 20120605190808) do
create_table "occupations", :force => true do |t|
t.string "name"
@@ -26,6 +26,7 @@
t.integer "occupation_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.boolean "evil"
end
end
@@ -14,6 +14,7 @@ describe "EditPersonView", ->
it "renders fields", ->
expect(@editPersonView.$("input[name='first_name']")).toExist()
expect(@editPersonView.$("select[name='occupation_id']")).toExist()
+ expect(@editPersonView.$("input[name='evil'][type=checkbox]")).toExist()
describe "saving", ->
beforeEach ->
jasmine.Ajax.useMock()
@@ -5,7 +5,7 @@ class Backtastic.Views.FormView extends Backtastic.View
@fieldViews = {}
fieldView: (fieldViewClass, options) ->
- fieldView = new fieldViewClass _.extend options,
+ fieldView = new fieldViewClass _.extend options,
parentView: @
model: @model
@fieldViews[options.field] = fieldView
@@ -16,6 +16,9 @@ class Backtastic.Views.FormView extends Backtastic.View
textField: (options) ->
@fieldView(Backtastic.Views.TextFieldView, options)
+
+ checkBoxField: (options) ->
+ @fieldView(Backtastic.Views.CheckBoxView, options)
selectField: (options) ->
@fieldView(Backtastic.Views.SelectFieldView, options)

0 comments on commit 95e425e

Please sign in to comment.