dimanche 29 mars 2020

Rails & Haml - Submit button doesn't work after added a new input box

I have a haml file to generate the proposal submit page, the code is like this:

.row
  %fieldset.col-md-6
    =proposal.title_input(form)
    =proposal.description_input(form)
  %fieldset.col-md-6
    .row
      .col-md-3
        = form.label t('.choose_tags'), { class: 'tags-label' }
      .col-md-6.form-spacing
        = form.hidden_field :tags, { class: 'proposal-tags' }
        #tags-container.tags-container
.row
  .form-submit.clearfix
    .pull-left
      = submit_proposal_button(proposal)

It generates a proposal submitting page which allowed the user to edit the title and description of their proposal, and the proposal's tag as well. There's a submit button on the bottom to save it.

And I want to add another input box which allowed the user to update their self-introduction as well. So, I simply added it to this file:

    .row
      %fieldset.col-md-6
        =proposal.title_input(form)
        =proposal.description_input(form)
      %fieldset.col-md-6
        .row
          .col-md-3
            = form.label t('.choose_tags'), { class: 'tags-label' }
          .col-md-6.form-spacing
            = form.hidden_field :tags, { class: 'proposal-tags' }
            #tags-container.tags-container
      // ----- the following content is what I added.-----
      %fieldset.col-md-6
        = simple_form_for user, url: person_path(id: user.id), html: {role: 'form'} do |f|
          %h4= I18n.t('.your_profile')
          .form-group
            = f.input :bio, class: 'form-control', placeholder: I18n.t('.bio'),
              input_html: {rows: 7}, maxlength: 1500
    // ----- the above content is what I added.-----
    .row
      .form-submit.clearfix
        .pull-left
          = submit_proposal_button(proposal)

After I added it, the submit button couldn't work. Whenever I click on it, nothing happens. I'm a beginner of haml and rails, and I'm confusing about it. Any help is appreciated!

The code of submit_proposal_button is:

  def submit_proposal_button (proposal)
    capture_haml do
      haml_tag :button,
           type: 'submit',
           name: 'submit',
           value: proposal.id,
           class: 'btn btn-primary' do
        haml_concat(t('.form.submit'))
      end
    end
  end

Aucun commentaire:

Enregistrer un commentaire