I'm working on a bit of an extension for processing survey data (idea
from and partially based on questionnaire extension that is no longer
maintained).

I'm trying to use form_for, fields_for and various helpers that rails
provides inside pre-defined radius tags.

Is there any way I could achieve some like this:

  # ------ <r:survey:form>
-----------------------------------------------------

  tag 'survey:form' do |tag|

    # call form_for :survey_result here, which would render form
header

    tag.expand # render questions

    # form_for would end here, closes </form>

  end

  # ------ <r:survey:questions>
------------------------------------------------
  tag 'survey:questions' do |tag|
    tag.expand
  end

  # ------ <r:survey:questions:each>
-------------------------------------------
  tag 'survey:questions:each' do |tag|
    result = []
    survey = tag.locals.survey
    # fields_for :result_entries
    survey.survey_questions.sort_by{|q| q.order}.each do |question|
      tag.locals.question = question
      result << tag.expand
    end
    result
  end

  # ------ <r:survey:questions:each:question>
----------------------------------
  tag 'survey:questions:each:question' do |tag|
    question = tag.locals.question
    question.content
  end

  # ------ <r:survey:questions:each:answers>
----------------------------------
  tag 'survey:questions:each:question' do |tag|
    question = tag.locals.question
    # for each qa in question.answers
    # form.text_field :value
    # and so on
  end

I hope you get the idea.

Reply via email to