Orbit/app/views/admin/infos/_list_block.html.erb

46 lines
2.5 KiB
Plaintext
Raw Normal View History

<% temp_field_name = field_name.gsub /\[\D*\]$/,'[temp]'%>
<div class="control-group">
<%= hidden_field_tag "#{temp_field_name}[count]",((values.keys.collect{|t| t.to_i}.max rescue nil) || 0 ),:class=>"list_count"%>
<%= hidden_field_tag "#{temp_field_name}[name]",field_name,:class=>"field_name"%>
<label class="control-label" ><%= t("admin.infos.list")%></label>
<div class="multipleInput">
<%if values.blank? %>
<div class="controls">
<% @site_valid_locales.each do |locale| %>
<% last = (locale == @site_valid_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%>
<%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%>
<%= text_field("#{field_name}[0]", locale,:placeholder=>t("langs.#{locale}")) %>
<% if last %>
<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>
<% end %>
<% end %>
<% end %>
</div>
<%else%>
<%values.each do |index,value|%>
<div class="controls">
<% @site_valid_locales.each do |locale| %>
<% last = (locale == @site_valid_locales.last ? true : false) %>
<% p_value = value[locale.to_s] rescue nil%>
<%= content_tag :div,:class=>"input-append #{"unRadius" if last }" do%>
<%= text_field("#{field_name}[#{index}]", locale,:value=>p_value,:placeholder=>t("langs.#{locale}")) %>
<% if last %>
<a href="#" class="btn removeInput" type="button"><i class="icon-trash"></i></a>
<% end %>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
</div>
<div class="controls">
<span class="help-block">
<a href="#"><i class="icon-plus-sign"></i><%= t("admin.infos.add") %></a>
</span>
</div>
</div>