On Tue, Sep 21, 2010 at 4:21 PM, swartz <netv...@gmail.com> wrote:
> 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.
>


You'd need to include the modules into your tag module.
Something like

include ActionView::Helpers::FormHelper

and then you should be able to use those helpers.

Tags are rendered from models (Page) not from views like you do in a
typical rails app, so you're creating this content from a different
perspective.


-- 
Jim Gay
Saturn Flyer LLC
http://www.saturnflyer.com
571-403-0338

Reply via email to