Drextor
Drextor

Reputation: 433

Rails - Disable select_tags / textfields on view

I try to disable the fields with

disabled="true"

but this doesnt work. Someone any idea how i can fix this, because i want to insert a checkbox which must checked to activate all fields ?

<%= form_tag({ :controller => 'orders', :action => 'submit_customer_settings' }, :method => 'post', :name => 'submit_customer_settings', :class => "row") do %>

      <table>
          <tr>
              <td class="col-lg-2"></td>
              <td class="col-lg-2 hidden" id ="customer_service_beneficiary_header" name=customer_service ><%=  label_tag :customer_service_beneficiary, CartItem.human_attribute_name('beneficiary')%></td>
              <td class="col-lg-2 hidden" id ="business_partner_header" name=customer_service ><%=  label_tag :business_partner, CartItem.human_attribute_name('business_partner')%></td>
              <td class="col-lg-2" id ="customer_service_customer_header" name=customer_service ><%=  label_tag :customer_service_customer, CartItem.human_attribute_name('customer')%></td>
              <td class="col-lg-2" id ="customer_service_project_header" name=customer_service ><%= label_tag :customer_service_project, CartItem.human_attribute_name('project')%></td>
              <td class="col-lg-2" id ="topic_header" name=customer_service ><%= label_tag :topic,  CartItem.human_attribute_name('topic') %></td>
              <td class="col-lg-2"></td>
          </tr>
          <tr>
              <td class="col-lg-2" style="font-weight:bolder; font-size:20px;" ><%= CartItem.human_attribute_name('customer_service') %>
                  <span class="hidden" ><%= check_box_tag :customer_service, nil, true, :id => "customer_service"%></span>
              </td>

              <td class="col-lg-2 hidden" id ="customer_service_beneficiary" name=customer_service disabled="true"><%= select_tag(:customer_service_beneficiary_id,  options_for_select(customer_service_beneficiary_col) , :class => "form-control") %></td>
              <td class="col-lg-2 hidden" id ="business_partner" name=customer_service disabled="true"><%= typeahead_field_tag(:business_partner_id,  params[:business_partner_id], autocomlete_business_partner_path, :class => "form-control")%></td> 
              <td class="col-lg-2" id ="customer_service_customer"  name=customer_service disabled="true"><%= select_tag(:customer_service_customer_id, options_from_collection_for_select(@customer_service_customers, 'id', 'name', params[:customer_service_customer_id].to_i), :class => "form-control input-sm") %></td>
              <td class="col-lg-2" id ="customer_service_project"  name=customer_service disabled="true"><%= select_tag(:customer_service_project_id, options_from_collection_for_select(@customer_service_projects, 'id', 'identifier', params[:customer_service_project_id].to_i), :class => "form-control input-sm") %></td>
              <td class="col-lg-2" id ="topic"  name=customer_service disabled="true"><%= text_field_tag :topic,  params[:topic], :class => "form-control input-sm"%></td> 
              <td class="col-lg-2" style="text-align: left;"><%= submit_tag t("next"), :class => "btn btn-primary"%></td>
              <td class="col-lg-2" ></td>
          </tr>
      </table>

Upvotes: 1

Views: 41

Answers (1)

JohnPaul
JohnPaul

Reputation: 710

Try this,

<%= f.select :action_item_status, action_item_status, {}, {:disabled => true} %>

refer this link (http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M002302)

Upvotes: 2

Related Questions