Philip Hallstrom
2009-Apr-21 19:25 UTC
What is the reason that the authenticity_token hidden field gets wrapped in a DIV?
Hi all - This has never been an issue for me until today. However I have a form and Rails is inserting it''s hidden authenticity_token field. It wraps it in a div with a style. And doing that messes things up for me CSS wise. Which got me to thinking about why it''s wrapped at all? Hidden fields don''t take up any room. Why wrap it in a div which can have some side affects? And if we''re going to wrap it, why not at least give it a class so we can target it and set display:none which fixes the problem. Can anyone shed some light on why this is the case? If there''s no good reason it seems like the wrapped div should go away shouldn''t it? <form action="xxx" method="post"> <div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="xxxxx=" /></div> <input id="q" name="q" type="text" /> <input src="search.png" type="image" /> </form> -philip
Philip Hallstrom
2009-Apr-21 20:21 UTC
Re: What is the reason that the authenticity_token hidden field gets wrapped in a DIV?
Following up. Looks like I''m not the only one who doesn''t like this... https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2044 On Apr 21, 2009, at 12:25 PM, Philip Hallstrom wrote:> > Hi all - > > This has never been an issue for me until today. However I have a > form and Rails is inserting it''s hidden authenticity_token field. It > wraps it in a div with a style. And doing that messes things up for > me CSS wise. > > Which got me to thinking about why it''s wrapped at all? Hidden fields > don''t take up any room. Why wrap it in a div which can have some side > affects? And if we''re going to wrap it, why not at least give it a > class so we can target it and set display:none which fixes the > problem. > > Can anyone shed some light on why this is the case? If there''s no > good reason it seems like the wrapped div should go away shouldn''t it? > > > <form action="xxx" method="post"> > <div style="margin:0;padding:0"><input name="authenticity_token" > type="hidden" value="xxxxx=" /></div> > <input id="q" name="q" type="text" /> > <input src="search.png" type="image" /> > </form> > > -philip > > >
Rimantas Liubertas
2009-Apr-22 10:30 UTC
Re: What is the reason that the authenticity_token hidden field gets wrapped in a DIV?
> Can anyone shed some light on why this is the case? If there''s no > good reason it seems like the wrapped div should go away shouldn''t it?> <form action="xxx" method="post"> > <div style="margin:0;padding:0"><input name="authenticity_token" > type="hidden" value="xxxxx=" /></div> > <input id="q" name="q" type="text" /> > <input src="search.png" type="image" /> > </form>According to (X)HTML specification you cannot have inline elements inside form, so inputs must be wrapped in something: fieldset, p or div. Regards, Rimantas -- http://rimantas.com/
Philip Hallstrom
2009-Apr-22 15:57 UTC
Re: What is the reason that the authenticity_token hidden field gets wrapped in a DIV?
>> Can anyone shed some light on why this is the case? If there''s no >> good reason it seems like the wrapped div should go away shouldn''t >> it? > >> <form action="xxx" method="post"> >> <div style="margin:0;padding:0"><input name="authenticity_token" >> type="hidden" value="xxxxx=" /></div> >> <input id="q" name="q" type="text" /> >> <input src="search.png" type="image" /> >> </form> > > According to (X)HTML specification you cannot have inline elements > inside form, so inputs > must be wrapped in something: fieldset, p or div.Ah, that would explain it then! Thanks. To anyone else who has issues with this and CSS, check out the below patch. It works great on 2.3.2. Basically I can override the style and set it to display:none or display:inline... https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2044