Sha256: 928386f747b19e355da7c8d14d3554a3fef6f73c6e0b92707b24c1a5b3021f30

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Smithy
  module ApplicationHelper
    def smithy_link_to_add_fields(name, association, form_builder)
      html = content_tag(:div, :id => "#{association}_fields_blueprint", :style => "display:none;") do
        form_builder.semantic_fields_for(association, model_object(form_builder, association), :child_index => "new_#{association}") do |builder|
          form_builder.template.concat(raw render("#{form_builder.object.class.to_s.tableize}/#{association.to_s.singularize}_fields", :f => builder))
        end
      end
      form_builder.template.concat(html)
      form_builder.template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association)
    end

    def smithy_link_to_remove_fields(name, form_builder)
      form_builder.hidden_field(:_destroy) + @template.link_to(name, "javascript:void(0)", :class => "remove_nested_fields")
    end

    def render_markdown_input(fieldname, editor_name, form_builder)
      form_builder.input fieldname, as: 'markdown'
    end

    private
      def model_object(form_builder, association)
        model_object = form_builder.object.class.reflect_on_association(association).klass.new
      end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
smithycms-0.7.3 app/helpers/smithy/application_helper.rb
smithycms-0.7.2 app/helpers/smithy/application_helper.rb
smithycms-0.7.1 app/helpers/smithy/application_helper.rb
smithycms-0.7.0 app/helpers/smithy/application_helper.rb
smithycms-0.6.10 app/helpers/smithy/application_helper.rb
smithycms-0.6.9 app/helpers/smithy/application_helper.rb
smithycms-0.6.7 app/helpers/smithy/application_helper.rb
smithycms-0.6.6 app/helpers/smithy/application_helper.rb
smithycms-0.6.5 app/helpers/smithy/application_helper.rb
smithycms-0.6.4 app/helpers/smithy/application_helper.rb