thermans
thermans

Reputation: 1167

Mixing form and layout tags in HAML

I have a form (Rails) and want to separate the submit into a separate DIV from the form fields:

.row
  .span
    = form_for [@household, @payment], do |h|
      %fieldset
        = h.label :lastname
        = h.text_field :lastname
        -# etc etc

  .span
    = h.submit "Submit"

Haml indentation rules say the "submit" tag has to be 2 spaces from the ".span". But this breaks the form, which expects it to be indented on the same level as the "%fieldset".

How can I make this form split itself over two DIVs?

Upvotes: 1

Views: 1549

Answers (1)

jdoe
jdoe

Reputation: 15771

Try this to put your submit outside the fieldset:

.row
    = form_for [@household, @payment], do |h|
        %fieldset.span
            = h.label :title
            = h.text_field :title
            -# etc etc

        .span
            = h.submit "Submit"

BTW, if you think that there isn't possible way to make you template more concise then take a look at slim.

Upvotes: 1

Related Questions