When I create a form with form helpers and put it in invalid data, the fields that get added by the error tags get put all between quotes and a see in the html the following:
"<span class="fieldWithErrors"><label for="email">Email</label></span> <span class="fieldWithErrors"><input id="email" name="email" size="30" type="text" value="adfasd" /></span>"
Note the quotes around the whole text which means this is the actual text when browsing from a website.
The messages on top appear to be correct but for some reason, it adds these quotes around it all. Any idea why?
Related
At this point I'm just trying to getting the input from the form. When I hit submit it does nothing and show nothing in the terminal. I'm using Slim with Sinatra.
My two routes are
post '/user_search' do
puts params[:checkbox]
#slim :user_search_results
# commented because I just would like to see something in terminal.
end
get '/user_search_form' do
slim :user_search_form
end
I've tried creating a class for search as well as a helper method. None of those approaches have changed anything.
Finally here is the form. Granted I have some other forms that work find. Those use text fields, so maybe it is the checkboxes that are throwing things.
form method="POST" action="/user_search"
label for="mp3" mp3:
input type="checkbox" name="mp3" value="mp3"
label for="flac" flac:
input type="checkbox" name="flac" value="flac"
label for="ape" ape:
input type="checkbox" name="ape" value="ape"
label for="m4a" m4a:
input type="checkbox" name="m4a" value="m4a"
label for="jpg" jpg:
input type="checkbox" name="jpg" value="jpg"
label for="gif" gif:
input type="checkbox" name="gif" value="gif"
label for="png" png:
input type="checkbox" name="png" value="png"
input type="submit" value="Submit"
This is non database input. Just want to grab the params for a search method.
Wow, it all came down to indenting all the lines below action method. I also indented submit passed those above. Weird thing is other forms I have, have no indentation at all.
Hi i have the code like this
<label class="floating">
<input name="role[permissions][]" type="checkbox" value="project_reopen
asd">
Project reopen
Asd
</label>
In my Ruby code I put the value like this
puts 'project_reopen'+"\n"+'asd'.to_s.humanize
The value is displaying the line break but in view its not working
om/I7NDj.png
In HTML, like breaks are different. You should use <br> for that purpose:
<input name="role[permissions][]"
type="checkbox"
value="project_reopen<br>asd">
You should not expect any whitespace to be preserved in HTML as typed. Conseq spaces will be squeezed, etc.
To print the string that comes from not trusted source (like DB,) one should explicitly tell Rails it’s fine to use it as is:
value="<%= #string.html_safe %>"
I try to move my text analyzer from console to web form.
I have simple form like this:
<form action="/">
<textarea name="str"></textarea>
<input type="submit">
</form>
Generally I could have very long texts for analysis inside of textarea. When I submit the form I get the following from thin:
Invalid request: Header longer than allowed
So the question is what is the proper approach to send long texts to server? Uploading files or filling links to url are not the option unfortunately.
By default the method of a form is GET, which has a limit on the number of characters allowed. (The limit depends on server and client, see for instance this answer, which specifies that usually it is 8KB).
You should use instead a method POST, which has much larger limit, around 2GB.
<form action="/" method="POST">
<textarea name="str"></textarea>
<input type="submit">
</form>
I am trying to write the step definition, using Capybara, for a Cucumber scenario that is meant to confirm that checkboxes on the home page appear before the options.
Mechanically, I am trying to find the index of a specific html checkbox using its HTML ID and compare it with the index of a specific text on the home page. However, I have spent hours on this issue and have not been able to implement the step definition.
Would I for example be able to somehow convert the page into text and just search for words?
For this web application I am using Ruby on Rails.
Let: checkbox id = environment_Cool
Let: text on the page = Cool
I would greatly appreciate your help.
Suppose you have a checkbox like this:
<form action="demo_form.asp">
<span>
<input type="checkbox" name="coolness" value="Cool" id="environment_Cool" checked> Cool</span>
<br>
<span>
<input type="checkbox" name="coolness" value="Cool"> Not So Cool</span><br>
<input type="submit" value="Submit">
</form>
Mechanically, I am trying to find the index of a specific html
checkbox using its HTML ID
page.find('[#id=environment_Cool ]')
and compare it with the index of a specific text on the home page.
Then it should return the text at the parent of the checklist, which is "Cool".
puts page.find('[#id=environment_Cool ]').find(:xpath,".//..").text
Hy
What i want to do is to create a custom renderer for will_paginate which renders first, previous, next and last page and a input field where the user can type in the page number manually. I already have the links for first, last etc. but i stuck at the input field. I could create a form in the view but the input field has to be rendered between the previous and next links.
Does anyone know how to do this?
Thanks for your help
You can do this as a separate form (make sure it is a GET). All you
need is the one input element named page. Something as simple as this
should work (not all browsers may like the #). I dropped it into a
site I'm playing with now and it worked. Put it anywhere on your page.
You might have to make something more complicated if you need to
incorporate search terms.
<form action="#" method="get">
Go to page: <input type="text" name="page" value="" size="2"
maxlength="4" />
<input type="submit" name="btnSubmit" />
</form>