Sha256: 2780823a7490d50a7c68760f0f26de3c0bd026d09b75fa38c7f4c5408f933a9b

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

module ExpressTemplates
  module Components
    module Forms
      module BasicFields
        ALL = %w(email phone text password color date datetime
                datetime_local number range
                search telephone time url week)

        ALL.each do |type|
          class_definition = <<-RUBY
            class #{type.classify} < FormComponent
              contains {
                label_tag(label_name, label_text)
                #{type}_field_tag field_name_attribute, field_value, field_helper_options
              }
            end
RUBY

          eval(class_definition)

        end
      end

      class File < FormComponent
        contains {
          label_tag(label_name, label_text)
          file_field_tag field_name_attribute, field_helper_options
        }
      end

      class Textarea < FormComponent
        has_option :value, 'The initial textarea value'

        contains {
          label_tag(label_name, label_text)
          text_area_tag field_name_attribute, field_value, field_helper_options
        }

        def field_value
          config[:value] || super
        end
      end

      class Hidden < FormComponent
        contains {
          hidden_field_tag field_name_attribute, field_value, field_helper_options
        }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
express_templates-0.11.20 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.20.rc1 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.19 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.18 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.17 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.16 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.16.rc1 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.15 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.14 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.13 lib/express_templates/components/forms/basic_fields.rb
express_templates-0.11.11 lib/express_templates/components/forms/basic_fields.rb