Sha256: 91c89caa777bbbd2b6e35a7f0a9b08ad7ecdda9035c727b8e3bf69ca3053de02

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module FieldTypes
  module Core
    class TextCell < FieldTypes::Core::Cell
      def input
        render
      end

      def wysiwyg
        render
      end

      def multiline_input
        render
      end

      private

      def input_classes
        @options[:input_options]&.[](:display)&.[](:classes)
      end

      def input_styles
        @options[:input_options]&.[](:display)&.[](:styles)
      end

      def value
        data&.[]('text') || @options[:default_value]
      end

      def render_label_and_input
        render_label(:text) do
          render_input
        end
      end

      def render_label
        @options[:form].label 'data[text]', field.name, class: 'mdl-textfield__label'
      end

      def render_input
        @options[:form].text_field 'data[text]', value: value, placeholder: @options[:placeholder], class: 'mdl-textfield__input'
      end

      def render_wysiwyg
        @options[:form].cktext_area 'data[text]', value: value, class: input_classes, ckeditor: input_styles
      end

      def render_multiline_input
        @options[:form].text_area_tag 'data[text]', value: value # , cols: @options[:cols], rows: @options[:rows]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cortex-field_types-core-0.2.3 app/cells/field_types/core/text_cell.rb
cortex-field_types-core-0.2.2 app/cells/field_types/core/text_cell.rb