如果为true,则正确显示货币格式

时间:2016-02-10 20:18:52

标签: ruby-on-rails ruby haml

我有下表enter image description here

对于费率类型,这两个选项是“平面或百分比”。如果我指定Flat,我希望Institutional和Professional框以货币格式显示它。我以为我在代码中指定了Flat,但是当我将数字放在Institional和专业框中时,它仍然不显示货币格式。这是我的代码:

= form_for @payer_contract,:html => {:id => "add-payer-contract-form"} do |f|
  %table.table-base.table-striped{:id => "case-global-table"}
    %thead
      %tr
        %th= t('payer.contract.phase')
        %th= t('payer_contracts.rate_type')
        %th= t('payer_contracts.institutional')
        %th= t('payer_contracts.professional')
        %th
    %tbody
      .clone-wrapper
        - @payer_contract.phase_dates.each.with_index do |pd, index|
          =fields_for "phase_dates",pd do |p|
            %tr.clone-target{:id => 'phase-table-row', :name => 'payer_contract[phase][:i][desc]'}
              - @phase_name = t('payer_contracts.phase')+ ' ' +(index+1).to_s
              %td
                %input.field-input{type: 'text', readonly: 'readonly', placeholder: 'Phase', value: @phase_name}
              %td
                = p.select :rate_type, options_for_select(@rate_type, @selected_rate_type), :name=> "phase_dates[rate_type]-c#{index}", required: true, :style => 'width:125px'
              %td
                = p.text_field :institutional, :name=> "phase_dates[institutional]-c#{index}", class: 'field-input', 'currency-format' => (@rate_type == 'FLAT')
              %td
                = p.text_field :professional, :name=> "phase_dates[professional]-c#{index}", class: 'field-input', 'currency-format' => (@rate_type == 'Flat')
              %td
                %button.icon-fallback-text.clone-add{"aria-label" => "Add", :type => "button"}
                  %span.icon-add-square{"aria-hidden" => "true"}
                %button.icon-fallback-text.clone-remove{"aria-label" => "Remove", :disabled => @payer_contract.phase_dates.size > 1 ? false : true, :type => "button"}
                  %span.icon-remove-square{"aria-hidden" => "true"}

当我在Rate Type下检查“Flat”框2时,我发现:

<select id="phase_dates_rate_type-c1" name="phase_dates[rate_type]-c1" u-index="1" aria-invalid="false" class="valid"><option value="

有什么想法吗?

0 个答案:

没有答案