开发者

Is it possible to pass rails variables in the Radiant CMS?

I'm trying to set up a simple form for a mailing list.

And it doesn't seem to allow any rails helpers to make the form_for and fulfill the authenticity to开发者_StackOverflow中文版ken.

Anyone have any luck installing a simple form_for in Radiant?


In your /your_extension.rb :

def activate
  Page.send :include, YourCustomTags
end

your_custom_tags.rb

module YourCustomTags
  include Radiant::Taggable

  tag 'custom' do |tag|
    tag.expand
  end

  tag "custom:form" do |tag|
    tag.attr['id'] ||= 'newsletter'
    results = []
    action = "/newsletters/"
    results << %(<form action="#{action}" method="post" #{newsletter_attrs(tag)}>)
    results << %(<input name="authenticity_token" type="hidden" value="#{response.instance_variable_get(:@session)[:_csrf_token]}" />)
    results <<   tag.expand
    results << %(</form>)
  end

This will pass authenticity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜