Skip to content

Commit

Permalink
add route to submit form when button selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 committed Nov 3, 2024
1 parent 479f1d9 commit 2257871
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
4 changes: 4 additions & 0 deletions app/controllers/federal_tax_brackets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def destroy
end
end

def federal_tax_filing_status_select
@federal_tax_bracket = FederalTaxBracket.find(params[:fed_tax_table])
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
34 changes: 14 additions & 20 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,21 @@
</div>
</div>

<%= form_with model: @federal_tax_table_type, local: true do |form| %>
<div class="grid grid-cols-4">
<div class="flex">
<%= form.label :single %>
<%= form.radio_button :single, FederalTaxTableType.find_by(filing_status: 'single').id, required: true %>
<div class="py-4" id="federal_tax_status">
<strong>Filing status</strong>
<%= form_with url: federal_tax_filing_status_select_path, local: true do |form| %>
<div class="flex flex-row">
<% FederalTaxTableType.all.each do |table| %>
<div class="mx-auto">
<%= form.radio_button :fed_tax_table, table.id, onchange: "this.form.requestSubmit()" %>
<%= form.label :fed_tax_table, table.filing_status.humanize.capitalize %>
<!-- <input type="radio" value="<%#= table.id %>" name="tax_table" id="tax_table">-->
<!-- <label for="tax_table"><%#= table.filing_status.humanize.capitalize %></label>-->
</div>
<% end %>
</div>
<div class="flex">
<%= form.label :married_filing_jointly %>
<%= form.radio_button :married_filing_jointly, FederalTaxTableType.find_by(filing_status: 'married_filing_jointly').id %>
</div>
<div class="flex">
<%= form.label :married_filing_separately %>
<%= form.radio_button :married_filing_separately, FederalTaxTableType.find_by(filing_status: 'married_filing_separately').id %>
</div>

<div class="flex">
<%= form.label :head_of_household %>
<%= form.radio_button :head_of_household, FederalTaxTableType.find_by(filing_status: 'head_of_household') %>
</div>
</div>
<% end %>
<% end %>
</div>

<div id="final_income">
<%= render partial: "budget/salary_budget",
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
root "dashboard#index"
resources :incomes
post "/income_switch", to: "incomes#income_switch"
post '/federal_tax_filing_status_select', to: 'federal_tax_brackets#federal_tax_filing_status_select'
end

0 comments on commit 2257871

Please sign in to comment.