SpinaCMS / Spina

Spina CMS
http://www.spinacms.com
Other
2.19k stars 405 forks source link

[styling/bug] Structure field labels not showing #122

Closed KINKCreative closed 8 years ago

KINKCreative commented 8 years ago

It's a bit difficult to know what's what if a structure has many fields.

Please see: https://www.dropbox.com/s/tnj0nbvjgftqb1m/Screenshot%202016-03-19%2009.19.36.png?dl=0

nicolasthy commented 8 years ago

I suppose they never encountered this and when having only 2 or 3 fields you usually remember what's what. I understand though that in your case it's confusing. Also it isn't very elegant to add a label when there is so little space. However you can add them manually, it's pretty easy. You just have to create the following files: app/views/spina/admin/structure_partables/_line_form.html.haml

.horizontal-form-label
  = line_form.object.title
.horizontal-form-content
  = line_form.fields_for :structure_partable do |f|
    = f.text_field :content, placeholder: line_form.object.title

app/views/spina/admin/structure_partables/_text_form.html.haml

.horizontal-form-label
  = text_form.object.title
.horizontal-form-content
  = text_form.fields_for :structure_partable, text_form.object.structure_partable do |ff|
    = render 'spina/admin/shared/rich_text_field', form: ff, field: :content

app/views/spina/admin/structure_partables/_photo_form.html.haml

.horizontal-form-label
  = photo_form.object.title
.horizontal-form-content
  = link_to spina.photo_select_admin_photos_path(photo_form.object_name, selected_photo_id: (photo_form.object.structure_partable.id if photo_form.object.structure_partable.present?)), remote: true, class: "media_picker" do
    - if photo_form.object.structure_partable && photo_form.object.structure_partable.file.present?
      .placeholder.pull-right
        %span.button.button-small.button-round{data: {icon: 'U'}}=t 'spina.pages.photo_picker'
      .image
        = image_tag photo_form.object.structure_partable.file.thumb
    - else
      .placeholder
        %span.button.button-small.button-round{data: {icon: 'U'}}=t 'spina.pages.photo_picker'

    = photo_form.hidden_field :structure_partable_id

I took the same classes as for the default labels, however they don't affect the style of them. Go ahead and set your own if you want them to be displayed differently.

KINKCreative commented 8 years ago

Thank you, that's exactly what I did, overrode the specific form labels for the structure parts. Cheers!