Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Nested f.inputs blocks #848

Closed
TiagoCardoso1983 opened this Issue · 1 comment

2 participants

@TiagoCardoso1983

Hi,

I'm having a different behaviour in my project updating from the formtastic for rails 2 version (1.x) to the one for rails 3 (2.2.0) concerning nested f.input blocks. We previously had something like this:


- f.inputs do
%lt;li class="bang"%gt;
 - f.inputs do
= f.input :bla, .....

that would nest ol elements. I don't recall if the previous version nested ols inside ols without setting an in-between li (maybe that was the reason for the update, and why somebody wrote that li in between).


%lt;ol%gt;
%lt; li class="bang%gt;
%lt; ol%gt;
%lt;li class="input%gt;
%lt;input ..../%gt;
%lt;/li%gt;
%lt;/ol%gt;
%lt;/li%gt; 
%lt;/ol%gt;

All i know is that, if I do the same with the newest version, the ols don't get nested anymore, but an empty li is created instead, before the input element gets written.



%lt;ol%gt;
%lt;li class="bang"%gt;
%lt;li class="input%gt;
%lt;input .../%gt;
%lt;/li%gt;
%lt;/ol%gt;


Well, I don't have anything against it not nesting the list using the same f element (I do think it is cleaner this way), but I end up with an empty li I don't have an use for anymore and an "ignored" second f.inputs call.

Basically, in such cases, I would rather have a warning message in the log, or an explicit Exception thrown. This would be especially important for projects updating to rails 3, whose forms will silently "fail" in such cases, the styling remaining as the only way to actually perceive the different behaviour.

Unless there is a reason why this was made this way that I'm not following.

Regards,
Tiago

@justinfrench
Owner

@TiagoCardoso1983 Hi, yes, we added the needed <li> automatically in in the 2.0.0.rc. This note was added to the CHANGELOG: "Changed nested inputs() blocks to be automatically wrapped in an <li> tag to preserve HTML validity". This was a backwards incompatible change, and one of many reasons for the bump to 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.