Sha256: edfccb4ab107aad1edbcc817d5c47486e9a09eba6aacb7dc88c234e634ee98a7

Contents?: true

Size: 1.28 KB

Versions: 17

Compression:

Stored size: 1.28 KB

Contents

<%
  field_name = "#{field.to_s.singularize}_id"
  field_id = "#{model.underscore}_#{field_name}"

  remote = field_setting(model, field, :remote)
  unless remote.blank?
    field_remote_name = remote[:field]
    fk = remote[:fk] || field.to_s.singularize
		remote_model = remote[:model] || model
    onchange = "updateFieldRemote('#{model_link(application, remote_model)}', '#{model.underscore}', '#{fk}', '#{field_remote_name}', $('##{field_id}').val())"
  end
  onchangesettings = field_setting(model, field, :onchange)
  onchange = onchangesettings unless onchangesettings.blank?

	collection = field_collection(application, model, field, object)
	collection.insert(0, ['',0])
	
	collection_selected = object.send(field.to_s.singularize).id unless object.send(field.to_s.singularize).blank?
	
	klass = field_setting(model, field, :class) || "input-xlarge"
%>


<% if object.respond_to? field_name %>
  <%= form.select field_name, options_for_select(collection, collection_selected), {}, { :onchange => onchange, :class => "select2-me #{klass}", "data-placeholder" => "Selecione" } %>
<% else %>
  <%= select_tag "#{model.underscore}[#{field_name}]", options_for_select(collection, collection_selected), { :onchange => onchange, :class => "select2-me #{klass}", "data-placeholder" => "Selecione" } %>
<% end %>

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
my_admin-0.1.6 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.1.5 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.1.4 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.1.3 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.1.2 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.1.1 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.12 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.11 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.10 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.9 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.8 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.7 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.6 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.5 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.4 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.3 app/views/my_admin/fields/edit/type/belongs_to.html.erb
my_admin-0.0.2 app/views/my_admin/fields/edit/type/belongs_to.html.erb