2017-06-06 7 views
0

を与えることはできません、私はまだこれが壊れた理由については不明だ:ハム壊れ。違法ネスティング:コンテンツの両方が同じ行に

.form-box 
     %h3 Restrictions 
     %legend Restricted Locations 
     = form_for [:blueadmin, :wine, @wine], html: {class: 'form-horizontal col-lg-2'} do |f| 
      %fieldset.inputs 
      .control-group 
       = f.label :us_states, "US States", class: 'control-label' 
       .controls 
       = f.collection_select :product, Restriction.all, :us_state, :us_state, {}, :multiple => 'true' 
      %fieldset 
      %ol 
       %li.button 
       = f.submit "Submit", class: 'btn btn-primary' 
     %table.table.table-hover.table-condensed.story-list 
     %th State 
     %th Remove 

私が手にエラーがある: Illegal nesting: content can't be both given on the same line as %legend and nested within it.

= form_forがあると思われます犯人

私は制限された場所が%legendと同じ行にあることを理解していますが、それがドキュメントの表示方法です。

しかしこれは動作しますが、それネジアップ私の凡例のボーダー:

.form-box 
     %h3 Restrictions 
     %legend 
     Restricted Locations 
     = form_for [:blueadmin, :wine, @wine], html: {class: 'form-horizontal col-lg-2'} do |f| 
      %fieldset.inputs 
      .control-group 
       = f.label :us_states, "US States", class: 'control-label' 
       .controls 
       = f.collection_select :product, Restriction.all, :us_state, :us_state, {}, :multiple => 'true' 
      %fieldset 
      %ol 
       %li.button 
       = f.submit "Submit", class: 'btn btn-primary' 
    %table.table.table-hover.table-condensed.story-list 
     %th State 
     %th Remove 

それは次のようになります。これに代えて

enter image description hereenter image description here

(方法に注意してください細い線は別の場所にあります)

最後に、フォームの右側に下の表が表示されるようにするにはどうすればよいですか?これを行うにはどうすればよいですか?

+0

にくぼみの結果の変更は、私はあなたが何をすべきかわからないので HAMLはインデントで動作します:あなたのケースでは、巣Restricted Locationsテキストだけでなく、form

注意しようとしています'= form_for'です。 hamlで 'form_for'を使うときはいつでも' - form_for'です。 – stef

答えて

1

凡例要素内にネストされたフォームがあります。

.form-box 
    %h3 Restrictions 
    %legend 
    Restricted Locations 
    = form_for [:blueadmin, :wine, @wine], html: {class: 'form-horizontal col-lg-2'} do |f| 
    %fieldset.inputs 
     .control-group 
     = f.label :us_states, "US States", class: 'control-label' 
     .controls 
      = f.collection_select :product, Restriction.all, :us_state, :us_state, {}, :multiple => 'true' 
    %fieldset 
     %ol 
     %li.button 
      = f.submit "Submit", class: 'btn btn-primary' 
%table.table.table-hover.table-condensed.story-list 
    %th State 
    %th Remove 
0

%legendタグからフォームを移動する必要があります。

変更し、これにコード:あなたが巣に単一の要素を持っている場合にのみ

.form-box 
    %h3 Restrictions 
    %legend 
    Restricted Locations 
    = form_for [:blueadmin, :wine, @wine], html: {class: 'form-horizontal col-lg-2'} do |f| 
    %fieldset.inputs 
     .control-group 
     = f.label :us_states, "US States", class: 'control-label' 
     .controls 
      = f.collection_select :product, Restriction.all, :us_state, :us_state, {}, :multiple => 'true' 
    %fieldset 
     %ol 
     %li.button 
      = f.submit "Submit", class: 'btn btn-primary' 
    %table.table.table-hover.table-condensed.story-list 
    %th State 
    %th Remove 

使用インラインコンテンツ。別のHTMLコードまたは構文エラー

関連する問題