Hi Jim, Thank you for replying.
I have been down that road before, I had to do this include ActionView::Helpers::FormHelper (for form_for) include ActionView::Helpers::FormTagHelper (for form_tag) include ActionController::RequestForgeryProtection ( for protect_from_forgery?). But after doing all this, it continued to complain: "undefined method form_tag" So I gave up after being unable to make any progress. I realize that tags have access to Page attributes/methods only. So i've tried going via response object that is available to Page tags. Is what I'm trying to do even makes sense? I just want deal with form input (with nested model attributes) more easily. On Sep 26, 12:06 pm, Jim Gay <[email protected]> wrote: > On Tue, Sep 21, 2010 at 4:21 PM, swartz <[email protected]> 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 LLChttp://www.saturnflyer.com > 571-403-0338
