調査データを処理する Radiant CMS のちょっとした拡張に取り組んでいます。form_for、fields_for、およびレールが事前定義された半径タグ内で提供するさまざまなヘルパーを使用しようとしています。これらのタグは、Radiant ページで調査を生成します。
Radiantとの統合について私が考えていることは次のとおりです。
<r:survey id="200">
<r:survey:form> #<-- call to form_for
<r:survey:questions:each> # <-- calls fields_for
<r:question> # <-- renders question
<r:answer_field> #<-- renders input via text_field, text_area, etc
</r:survey:questions:each>
</r:survey:form>
</r:survey>
したがって、<r:survey:form> を呼び出すと、<form> タグが生成されると想定されます。htmlを手作りすればできるのですが、form_forヘルパーなどを利用したいです。
次のことを達成できる方法はありますか?
# ------ <r:survey:form> -----------------------------
tag 'survey:form' do |tag|
# call form_for which would render form header and open <form> tag
tag.expand
# 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
# should call fields_for here
survey.survey_questions.sort_by{|q| q.order}.each do |question|
tag.locals.question = question
result << tag.expand
end
# end of fields_for
result
end
これが私が達成しようとしていることを説明することを願っています。