% subsection_id ||= nil %>
<% show_unauthorized_columns = active_scaffold_config.send(form_action).show_unauthorized_columns %>
<%= "style=\"display: none;\"" if columns.collapsed %>>
<% columns.each :for => @record, :crud_type => (:read if show_unauthorized_columns) do |column| %>
<% authorized = show_unauthorized_columns ? @record.authorized_for?(:crud_type => form_action, :column => column.name) : true %>
<% renders_as = column_renders_as(column) %>
<% if renders_as == :subsection -%>
<% subsection_id = sub_section_id(:sub_section => column.label) %>
-
<%= column.label %>
<%= render :partial => 'form', :locals => { :columns => column, :subsection_id => subsection_id, :form_action => form_action } %>
<%= link_to_visibility_toggle(subsection_id, {:default_visible => !column.collapsed}) -%>
<% elsif column.readonly_association?
next %>
<% elsif renders_as == :subform and !override_form_field?(column) and authorized -%>
-
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column } -%>
<% else -%>
-
<%=raw render :partial => form_partial_for_column(column, renders_as), :locals => { :column => column, :only_value => !authorized } -%>
<% end -%>
<% end -%>