<commit_before><div class="asset_form">

  <%= f.error_messages -%>

  <% if @sample.new_record? %>
      <div class="form-group">
      <%= f.select :sample_type_id,
                   options_for_select(SampleType.all.collect { |st| [st.title, st.id] }, @sample.sample_type_id),
                   {:include_blank => 'Please select the appropriate Sample type' },:class => 'form-control' %>
      </div>
  <% end %>

  <div id="sample_attributes">
    <%= render :partial=>"sample_attributes_form",:locals=>{sample:@sample} %>
  </div>

  <%= f.submit (@sample.new_record? ? "Create" : "Update"), :class => 'btn btn-primary',:id=>'submit_sample_button',disabled:@sample.sample_type.nil? %>

</div>

<script>
    $j('#sample_sample_type_id').on('change', function () {
        if (this.value) {
            $j.ajax({
                url:"<%= attribute_form_samples_path %>",
                type: "get",
                data: {sample_type_id: this.value},
                dataType: "json",
                success: function(data) {
                    var replacement = "<div id='sample_attributes'>"+data["form"]+"</div>"
                    $j('#sample_attributes').replaceWith(replacement);
                    $j('#submit_sample_button').prop('disabled',false);
                },
                error: function(data) {
                    $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
                    $j('#submit_sample_button').prop('disabled',true);
                }<commit_msg>cancel button on sample form<commit_after><div class="asset_form">

  <%= f.error_messages -%>

  <% if @sample.new_record? %>
      <div class="form-group">
      <%= f.select :sample_type_id,
                   options_for_select(SampleType.all.collect { |st| [st.title, st.id] }, @sample.sample_type_id),
                   {:include_blank => 'Please select the appropriate Sample type' },:class => 'form-control' %>
      </div>
  <% end %>

  <div id="sample_attributes">
    <%= render :partial=>"sample_attributes_form",:locals=>{sample:@sample} %>
  </div>

  <%= f.submit (@sample.new_record? ? "Create" : "Update"), :class => 'btn btn-primary',:id=>'submit_sample_button',disabled:@sample.sample_type.nil? %>
    or
  <%= cancel_button(@sample.new_record? ? samples_path : sample_path(@sample)) %>
</div>

<script>
    $j('#sample_sample_type_id').on('change', function () {
        if (this.value) {
            $j.ajax({
                url:"<%= attribute_form_samples_path %>",
                type: "get",
                data: {sample_type_id: this.value},
                dataType: "json",
                success: function(data) {
                    var replacement = "<div id='sample_attributes'>"+data["form"]+"</div>"
                    $j('#sample_attributes').replaceWith(replacement);
                    $j('#submit_sample_button').prop('disabled',false);
                },
                error: function(data) {
                    $j('#sample_attributes').replaceWith("<div id='sample_attributes'/>");
                    $j('#submit_sample_button').prop('disabled',true);
                }
{'fraction_non_alphanumeric': 0.17692062480076506, 'fraction_numerical': 0.0, 'mean_word_length': 2.399783315276273, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 50, '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': '6416085', 'n_tokens_mistral': 973, 'n_tokens_neox': 905, 'n_words': 140}