开发者

Grid forms in Rails

I am trying 开发者_运维百科to create a grid form for a survey question.

            value1     value2   value3

option 1      x

option 2                 x

option 3      x

Each cell in the grid is a radio button and the radio buttons in a row belong to one radio button group.

My models:

class Question
  # title
  has_many :answers
end

class Answer
  # name, position, atype(row/col)  
end

Sample data for questions:

id  title
--  ------
1   Rate the following movies

Sample data for answers:

id  question_id  atype   position   name
--  -----------  -----   --------   --------
1   1            row     1          God Father
2   1            row     2          Star Wars
3   1            row     3          Aliens

4   1            col     1          Bad
5   1            col     2          Average
6   1            col     3          Good

I am struggling to come up with a Rails approach for creating such a form. To complicate the issue user can save the semi-completed form and complete it at a later time.

What is the best approach for this problem?


You might want to try formastic http://github.com/justinfrench/formtastic There are some great helpers in there that will help you archive your goal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜