ga-dc / wdi5-project4

3 stars 0 forks source link

submit buttons not working consistently #119

Closed Freetown5 closed 9 years ago

Freetown5 commented 9 years ago

My new submit button and my edit submit button are not working properly. Either they don't respond at all when clicked or they only respond when there is no content or occasionally when there is some content.

This is the controller

class BasicsController < ApplicationController

    def home
    end

    def index
      @basics = Basic.all
    end

    def new
      @basics = Basic.new
    end

    def create
      @basics = Basic.create!(basic_params)
      redirect_to @basics
    end

    def show
      @basics = Basic.find(params[:id])
      # render :show
    end

    def create
      @basics = Basic.create!(basic_params)
      redirect_to @basics
    end

    def edit
      @basic = Basic.find(params[:id])
      # render :edit
    end

    def update
      @basic = Basic.find(params[:id])
      @basic.update!(basic_params)
        redirect_to @basic
    end

    def destroy
      @basic = Basic.find(params[:id])
      @basic.destroy
      # redirect_to "/interviewers"
    end

    def basic_params
      return params[:basic].permit(:yname, :ycity, :yphone, :yemail, :cname, :ccity, :cphone, :cemail, :date, :POClastname, :POCfirstname, :POCtitle, :reference, :position_info, :skills)
    end

  end

and the view for both the new and edit page look like this:

<%= render 'layouts/heading' %>
<h2>Edit Information</h2>

<div class="all-content">
  <div class="standard-side">
    <div class="basic">
        <h3>Basic Info</h3>
        <%= form_for @basic do |f| %>

        <p>Your Name:
        <%= f.text_field :yname %></p>

        <p>Your City/State/Zip:
        <%= f.text_field :ycity %></p>

        <p>Your Phone:
        <%= f.text_field :yphone %></p>

        <p>Your Email:
        <%= f.text_field :yemail %></p>

    </div>

    <div class= "companies">
        <h3>Company Info</h3>
        <p>Company Name:
        <%= f.text_field :cname %></p>

        <p>Company City/State/Zip
        <%= f.text_field :ccity %></p>

        <p>Company Phone
        <%= f.text_field :cphone %></p>

        <p>Company E-mail
        <%= f.text_field :cemail %></p>

    </div>
  </div>

    <div class="letter-content">
        <h3><span class= "secondary-color2">Main Content</span></h3>
        <p>Date: <%= f.text_field :date %></p>
        <p>Point of Contact first name: <%= f.text_field :POCfirstname %> LastName: <%= f.text_field :POClastname %></p>
        <p>Dummy Data</p>
        <p>(Dear Ms./Mrs./Mr.) Point of Contact last name: <%= f.text_field :POClastname %></p>
        <p>I was recently made aware of a job opportunity at
            "Company Name"
          by <em><span class="secondary-color">reference:</span></em><%= f.text_field :reference %>. I was excited to learn about this position because <em><span class="secondary-color">relavent position related information:</span></em><%= f.text_field :position_info %>. I believe that I could be the perfect candidate for the position because <em><span class="secondary-color">relevant skills:</span></em><%= f.text_field :skills %>. Thank you for taking the time to go over my credentials, I hope to get the chance to meet with you soon.
        </p>

        <p>Sincerely yours/Yours Truly/Best Wishes</p>
        <p>"Your Name"</p>

        <div class= "centered-button2">
          <%= f.submit %>
        </div>
        <% end %>

    </div>
</div>
RobertAKARobin commented 9 years ago

It looks like your forms aren't nested properly. I'd recommend going back to that page, viewing the source code (Command + Option + U in Chrome on a Mac), and validate your HTML: http://validator.w3.org/#validate_by_input

Freetown5 commented 9 years ago

Okay so I fixed it. The issue was that I started the form inside one of the inner divs instead of on the inside of the outer most div, making it so that the form wasn't able to capture all of the inputs. I still have validation issues but the app itself is working now. Thanks.

RobertAKARobin commented 9 years ago

Glad that fixed it!