Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:38:32+00:00 2026-06-09T11:38:32+00:00

The html snippet: <table id=project_1> <thead> … <tr> <form accept-charset=UTF-8 action=/projects/1/tasks class=add-task form-search data-remote=true

  • 0

The html snippet:

<table id="project_1">
  <thead>
    ...
    <tr>
      <form accept-charset="UTF-8" action="/projects/1/tasks" class="add-task form-search" 
        data-remote="true" id="new_task" method="post"></form>
      <th><input class="input-xlarge" id="task_content" name="task[content]" 
        placeholder="Start typing here to create a task..." size="50" type="text"></th>
      <th><input class="btn" name="commit" type="submit" value="Add Task"></th>
    </tr>
  </thead>
  ...
</table>

The rspec test with capybara:

it "should create a task", :js => true do
  visit projects_path
  within("#project_#{@project.id}") do
    fill_in "task[content]", :with => "This is a new task"
    save_and_open_page
    click_button 'Add Task'
  end
  page.should have_content("This is a new task")
end

Capybara successfully found all elements on a page, but in the page (generated by save_an_open_page) the field ‘task[content]’ is empty.

What might be a problem here? Thanks

UPDATE:

The html code generated from this erb:

...
<%= form_for [project, Task.new], html: { :class => "add-task form-search" }, remote:   true do |f| %>
  <th><%= f.text_field :content, :class => "input-xlarge", :placeholder => "Start typing here to create a task...", :size => 50 %></th>
  <th><%= f.submit "Add Task", :class => "btn" %></th>
<% end %>
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:38:33+00:00Added an answer on June 9, 2026 at 11:38 am

    UPDATE:

    The closed tag (noticed by @Steve) may indeed be your problem. Here is someone with the same problem: form_for closes <form> tag

    I suspect the problem may be your HTML tags in the form. What if you remove the table row/header tags, like this:

    <%= form_for [project, Task.new], html: { :class => "add-task form-search" }, remote:   true do |f| %>
      <%= f.text_field :content, :class => "input-xlarge", :placeholder => "Start typing here to create a task...", :size => 50 %>
      <%= f.submit "Add Task", :class => "btn" %>
    <% end %>
    

    See if that generates the correct HTML first (with the <form> tags wrapping the <input> tags, and then see if that makes the spec pass.

    ORIGINAL ANSWER:

    I suspect that the problem is not with fill_in, but with what happens after it (adding the task). In my own test, I found that save_and_open_page does not show the text in the actual field even when the test actually does work. Are you sure there is not a problem with adding the new task to the page after form submission?

    Other things to try:

    1. Remove the within block and see if it works.
    2. Try using the field’s id instead of its name in fill_in, i.e.: fill_in "task_content", :with => "This is a new task"' and see if that works.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML (a snippet): <td class=ms-vb-title height=100%> <table class=ms-unselectedtitle onmouseover=OnItem(this) ctxname=ctx1
I am trying to add a html snippet dynamically which contains named anchors and
I have a HTML code snippet: <table> <tr> <th>a header</th> <td>some content</td> </tr> </table>
I have a sortable table in html and looking to put an add.png inside
This is a snippet of my code. soup=BeautifulSoup(html_document) tabulka=soup.find(table,width=100%) dls=tabulka.findAll(dl,{class:resultClassify}) tps=tabulka.findAll(div,{class:pageT clearfix}) return render_to_response('result.html',{'search_key':search_key,'turnpages
I have a HTML snippet like the following <tr class=new> <td> <input name=id type=checkbox/>
The following is a snippet from my HTML form which pulls the options from
I am working on loading a HTML table snippet into a page via jQuery
I am converting MySQL table into HTML table using this PHP snippet, and it
I have the following html snippet <table> <tr> <td><select name=day> </select></td> <td><select name=time> </select></td>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.