<commit_before><%
begin
  remote_controller = active_scaffold_controller_for(column.association.klass)
rescue ActiveScaffold::ControllerNotFound
  remote_controller = nil
end
@record = parent_record

show_add_existing = column_show_add_existing(column)
show_add_new = column_show_add_new(column, associated, @record)

return unless show_add_new or show_add_existing

edit_associated_url = params_for(:action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope) if show_add_existing
add_new_url = params_for(:action => 'edit_associated', :child_association => column.name, :scope => scope) if show_add_new

-%>
<div class="footer-wrapper">
  <div class="footer">
    <% if show_add_new -%>
    <% if column.plural_association?
         add_label = as_(:create_another, :model => column.association.klass.model_name.human)
         add_class = 'as_create_another'
       else
         add_label = as_(:replace_with_new)
         add_class = 'as_replace_with_new'
       end
       create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %>
    <%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
    <%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
    <% end -%>

    <%= '|' if show_add_new and show_add_existing %>

    <% if show_add_existing -%>
      <% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
        <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{edit_associated_url.to_json}, #{active_scaffold_id.to_json}, id);" -%>
      <% else -%>
        <% select_options = options_from_collection_for_select(sorted_association_options_find(column.association), :id, :to_label)
           add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing"
           add_existing_label = column.plural_association? ? :add_existing : :replace_existing %>
        <%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
        <%= link_to as_(add_existing_label), edit_associated_url, :id => add_existing_id, :remote => true, :class=> "as_#{add_existing_label}", :style => "display: none;" %>
        <%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %>
      <% end -%>
    <% end -%>
  </div>
</div>
<commit_msg>Fix error with 'Add existing record' using record_select<commit_after><%
begin
  remote_controller = active_scaffold_controller_for(column.association.klass)
rescue ActiveScaffold::ControllerNotFound
  remote_controller = nil
end
@record = parent_record

show_add_existing = column_show_add_existing(column)
show_add_new = column_show_add_new(column, associated, @record)

return unless show_add_new or show_add_existing

edit_associated_url = params_for(:action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope) if show_add_existing
add_new_url = params_for(:action => 'edit_associated', :child_association => column.name, :scope => scope) if show_add_new

-%>
<div class="footer-wrapper">
  <div class="footer">
    <% if show_add_new -%>
    <% if column.plural_association?
         add_label = as_(:create_another, :model => column.association.klass.model_name.human)
         add_class = 'as_create_another'
       else
         add_label = as_(:replace_with_new)
         add_class = 'as_replace_with_new'
       end
       create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %>
    <%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
    <%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
    <% end -%>

    <%= '|' if show_add_new and show_add_existing %>

    <% if show_add_existing -%>
      <% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
        <%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{url_for(edit_associated_url).to_json}, #{active_scaffold_id.to_json}, id);" -%>
      <% else -%>
        <% select_options = options_from_collection_for_select(sorted_association_options_find(column.association), :id, :to_label)
           add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing"
           add_existing_label = column.plural_association? ? :add_existing : :replace_existing %>
        <%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
        <%= link_to as_(add_existing_label), edit_associated_url, :id => add_existing_id, :remote => true, :class=> "as_#{add_existing_label}", :style => "display: none;" %>
        <%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %>
      <% end -%>
    <% end -%>
  </div>
</div>

{'fraction_non_alphanumeric': 0.144024912417283, 'fraction_numerical': 0.0, 'mean_word_length': 4.879862700228833, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5107945', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1669, 'n_words': 277}