Padrino Admin Screen

83 views Asked by At

I am working on the Padrino admin screen and would like to show a dropdown list using haml in the edit view. In the List view I would like to show the country name rather than the id number it shows is this possible? I am a very newbie to haml.

I am using countries and states

_form.haml

<code>
- error = @province.errors.include?(:countries_id)
%fieldset.control-group{:class => error ? 'has-error' : ''}
  =f.label :countries_id, :class => 'control-label'
  .controls
    =f.select(:countries_id, :collection => @cntrylist, :fields => [:country_name, :id], :selected => :id, :include_blank => false , :class => :dropdown, :prompt => "Select Province/State")
    %span.help-inline=error ? f.error_message_on(:countries_id, :class => 'dropdown-error') : pat(:example)
- error = @province.errors.include?(:province_name)
%fieldset.control-group{:class => error ? 'has-error' : ''}
  =f.label :province_name, :class => 'control-label'
  .controls
    =f.text_field :province_name, :class => 'form-control input-large input-with-feedback'
    %span.help-inline=error ? f.error_message_on(:province_name, :class => 'text-error') : pat(:example)
- error = @province.errors.include?(:province_code)
%fieldset.control-group{:class => error ? 'has-error' : ''}
  =f.label :province_code, :class => 'control-label'
  .controls
    =f.text_field :province_code, :class => 'form-control input-large input-with-feedback'
    %span.help-inline=error ? f.error_message_on(:province_code, :class => 'text-error') : pat(:example)

.form-actions
  =f.submit pat(:save), :class => 'btn btn-primary'
  &nbsp;
  =f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue'
  &nbsp;
  =link_to pat(:cancel), url(:provinces, :index), :class => 'btn btn-default'
 </code>

This works as expected for new but for edit I would prefer to display the dropdown rather than id which it shows

index.haml

%tbody
          [email protected] do |province|
            %tr.list-row
              %td.list-column.list-selectable
                  =check_box_tag 'province_ids[]', :value => province.id, :class => 'list-selectable-checkbox'
              %td.list-column=province.id
             %td.list-column=province.countries_id

... In the td.list column where it shows the countries_id I would like to have this as the country_name.

Thanks

0

There are 0 answers