Sha256: db7d66ee14c5de6ec5272dd3d26dc80fab57d46b8d8578c3bb2d5f252ffd2874

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

:ruby
  select_params = [name]


  if local_assigns.key? :select_options
    select_params.push select_options
  else
    collection = f.object.class.reflect_on_association(name.sub(/_id$/, '').to_sym).try(:klass).try(:all)
    select_params.push options_from_collection_for_select(collection, :id, resource_to_text_method(collection.first), f.object.send(name))
  end

  if local_assigns.key? :options
    select_params.push options
  end
  if local_assigns.key? :html_options
    select_params.push html_options
  end

  include_blank = true
  f.object.class.validators_on(name).each do |validator|
    if validator.is_a? ActiveModel::Validations::PresenceValidator
      include_blank = f.object.new_record?
      break
    end
  end
  select_params.push Hash[:include_blank, include_blank]

.field.type_item{ 'data-name' => name }
  .label_wrap><= f.label name, name.to_s.humanize + ':'
  .value><= f.select *select_params
  .clear

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
releaf-0.1.2 app/views/releaf/base/_edit.field_type_item.html.haml