Sha256: 8b6a5b0e42ea6dab3451d3f7aeb3bbc2fc1229f6e3676cd277b1afd30b1d723e

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

module MuckContentsHelper
  
  # share is an optional share object that can be used to pre populate the form.
  # content:  Optional content object to be edited.
  # options:  options for form.  For example:
  #           :url => 'some-url', :html => {:id => 'a form'}
  def content_form(content = nil, options = {}, &block)
    content ||= Content.new
    options[:html] = {} if options[:html].nil?
    url = options[:url] || get_content_form_url(@parent, @content)
    raw_block_to_partial('contents/form', options.merge(:url => url, :content => content), &block)
  end
  
  # content uses friendly_id but we want the param in the form to use the number id
  def get_content_form_url(parent, content)
    if content.new_record?
      polymorphic_url([parent, content])
    else
      # HACK there should be a way to force polymorphic_url to use an id instead of to_param
      polymorphic_url([@parent, @content]).gsub(@content.to_param, "#{@content.id}") # force the id.  The slugs can cause problems during edit
    end
  end
  
  def show_preview(content)
    if content.new_record?
      %Q{<a style="display:none;" target="blank" id="preview" href="#">#{t('muck.contents.preview')}</a>}
    else
      %Q{<a id="preview" target="blank" href="#{content.uri}">#{t('muck.contents.preview')}</a>}
    end
  end
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
muck-contents-3.1.7 app/helpers/muck_contents_helper.rb
muck-contents-3.1.6 app/helpers/muck_contents_helper.rb
muck-contents-3.1.5 app/helpers/muck_contents_helper.rb
muck-contents-3.1.4 app/helpers/muck_contents_helper.rb
muck-contents-3.1.3 app/helpers/muck_contents_helper.rb
muck-contents-3.1.2 app/helpers/muck_contents_helper.rb
muck-contents-3.1.1 app/helpers/muck_contents_helper.rb
muck-contents-3.1.0 app/helpers/muck_contents_helper.rb
muck-contents-3.0.2 app/helpers/muck_contents_helper.rb
muck-contents-3.0.1 app/helpers/muck_contents_helper.rb
muck-contents-3.0.0 app/helpers/muck_contents_helper.rb
muck-contents-0.2.27 app/helpers/muck_contents_helper.rb
muck-contents-0.2.26 app/helpers/muck_contents_helper.rb
muck-contents-0.2.25 app/helpers/muck_contents_helper.rb
muck-contents-0.2.24 app/helpers/muck_contents_helper.rb
muck-contents-0.2.23 app/helpers/muck_contents_helper.rb
muck-contents-0.2.22 app/helpers/muck_contents_helper.rb
muck-contents-0.2.21 app/helpers/muck_contents_helper.rb
muck-contents-0.2.20 app/helpers/muck_contents_helper.rb
muck-contents-0.2.18 app/helpers/muck_contents_helper.rb