jeudi 23 juin 2016

how to check check_box_tag is checked or not in rails

how to check check_box_tag is checked or not in rails?

I need to know what checkboxes is checked.

This system is to users generate reports baseds on options selects.

View:

<%= form_tag finish_reports_path do %>
    <div class="row top30 reload">
        <div class="col-sm-12 col-xs-12">
            <div class="form-inline">
                <%= check_box_tag("name", "1", false, class: "checkbox") %>
                <%= label_tag :name, "Nome do Conteúdo" %>
            </div>
            <div class="form-inline">
                <%= check_box_tag(:url, "2", false, class: "checkbox") %>
                <%= label_tag :url, "URL do Conteúdo" %>
            </div>
            <%= link_to t("button.generate"), finish_reports_path(finish: "yes"), :class => "btn btn-success" %>
        </div>
    </div>
<% end %>

Controller:

   def index
    end

    def finish
        redirect_to root_path
    end

Routes:

root "reports#index"
post "/" => "reports#read_combo", as: :read_reports_combo

get "/reports/generate/:type" => "generate#index", as: :reports_generate
get "/reports/generate" => "generate#finish", as: :finish_reports




Aucun commentaire:

Enregistrer un commentaire