form_for not rendering :html => {}

37 views
Skip to first unread message

Mendel

unread,
Jan 27, 2016, 4:01:51 PM1/27/16
to Ruby on Rails: Talk
Hi I am trying to disable chrome's html5 validations. I have added 
:html => {:novalidate => 'novalidate'}
to the form tag but when I check the form in the browser it is not there and the validations keep me from submitting the form.

Here is all the relevant (I think) code.

Enter code here...form_for(:customer, url: {:action => 'update', :id => @customer.id, :account_settings => true},:html => {:novalidate => 'novalidate'}) do |f|
          = render(:partial => 'form', :locals => {:f => f})

And this is what the form shows in HTML
<input class="form-control" id="customer_contact_email" name="customer[contact_email]" pattern="false" type="email">

Thank you.

Colin Law

unread,
Jan 28, 2016, 4:53:39 AM1/28/16
to Ruby on Rails: Talk
Are you saying the form tag does not show at all?
Is it ok in a different browser?
Have you got the = sign?
<%= form_for...

Colin

Mendel Schneerson

unread,
Jan 28, 2016, 9:53:33 AM1/28/16
to rubyonra...@googlegroups.com
Sorry I put the wrong line of HTML, the form works:

Here it is in Chrome

<form accept-charset="UTF-8" action="/customer/5" method="post">


What is interesting is that in Firefox the tag shows up and works fine:

<form accept-charset="UTF-8" action="/customer/5?account_settings=true"
method="post" novalidate="novalidate">

--
Posted via http://www.ruby-forum.com/.

Walter Lee Davis

unread,
Jan 29, 2016, 12:43:04 PM1/29/16
to rubyonra...@googlegroups.com

> On Jan 28, 2016, at 9:52 AM, Mendel Schneerson <li...@ruby-forum.com> wrote:
>
> Sorry I put the wrong line of HTML, the form works:
>
> Here it is in Chrome
>
> <form accept-charset="UTF-8" action="/customer/5" method="post">

Is this looking at the raw HTML, or the rendered DOM? Chrome *might* be being pedantic here, and refusing to show GET attributes in a POST form. I recall somewhere in the mists of time that while that may work, it may also not be *standard* and thus a conforming UA would be within its rights to drop it, since POST trumps GET in all cases. See if the form works uniformly when you add a hidden field to it with :account_settings as the name, and remove the querystring from the form action. If you add that with a f.hidden_field helper, then you will need to change your controller to access the attribute from within the parent object's params hash, i.e.: params[:customer][:account_settings] rather than params[:account_settings].

Walter

>
>
> What is interesting is that in Firefox the tag shows up and works fine:
>
> <form accept-charset="UTF-8" action="/customer/5?account_settings=true"
> method="post" novalidate="novalidate">
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bbecfb64afafc7414dbd6a51584ef941%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Jan 29, 2016, 1:28:04 PM1/29/16
to Ruby on Rails: Talk
On 29 January 2016 at 17:42, Walter Lee Davis <wa...@wdstudio.com> wrote:
>
>> On Jan 28, 2016, at 9:52 AM, Mendel Schneerson <li...@ruby-forum.com> wrote:
>>
>> Sorry I put the wrong line of HTML, the form works:
>>
>> Here it is in Chrome
>>
>> <form accept-charset="UTF-8" action="/customer/5" method="post">
>
> Is this looking at the raw HTML, or the rendered DOM? Chrome *might* be being pedantic here, and refusing to show GET attributes in a POST form. I recall somewhere in the mists of time that while that may work, it may also not be *standard* and thus a conforming UA would be within its rights to drop it, since POST trumps GET in all cases. See if the form works uniformly when you add a hidden field to it with :account_settings as the name, and remove the querystring from the form action. If you add that with a f.hidden_field helper, then you will need to change your controller to access the attribute from within the parent object's params hash, i.e.: params[:customer][:account_settings] rather than params[:account_settings].

Further to this a good plan is to copy/paste the complete generated
html into the html validator
https://validator.w3.org/#validate_by_input

Often when different browsers behave differently for the a site is it
down to invalid html, which the two browsers are interpreting
differently.

Colin
Reply all
Reply to author
Forward
0 new messages