0
滑軌4.我試圖與標籤軌道/禁用
2文本加圖像創建一個單選按鈕
1)),與選項可以在標籤的圖像和選擇的單選按鈕(或不)殘疾人
我可以
有僅使用簡單的形式幫助解決解決1)用f.collection_radio_buttons
和2)f.input
...但我不能找到解決方案解決2分...? (不含js/Jquery)
謝謝你的幫忙。
滑軌4.我試圖與標籤軌道/禁用
2文本加圖像創建一個單選按鈕
1)),與選項可以在標籤的圖像和選擇的單選按鈕(或不)殘疾人
我可以
有僅使用簡單的形式幫助解決解決1)用f.collection_radio_buttons
和2)f.input
...但我不能找到解決方案解決2分...? (不含js/Jquery)
謝謝你的幫忙。
我會盡量回答自己:
此代碼解決了2點:
<%= f.collection_radio_buttons(:typepayment,
[[0,t(:radio_button_type_payment_None)], [1,t(:radio_button_type_payment_DirectDebit)], [2,t(:radio_button_type_payment_CreditCard)]],
:first,
:last,
item_wrapper_tag: :div
) do |b|
b.label { (condition_is_disabled ? b.radio_button(disabled: "\"disabled\"") : b.radio_button) + " "+
(b.value == 0 ? t(:radio_button_type_payment_None) : (b.value == 1 ? t(:radio_button_type_payment_DirectDebit) : t(:radio_button_type_payment_CreditCard))) +
(b.value != 0 ? image_tag("typepayment_#{b.value}.png", class: "img_type_payment") : "") }
end
%>
給collection_radio_buttons
塊代碼是在這裏建造Labee酒店與圖像。
disabled: "\"disabled\""
:我沒有發現其他方法將disabled
狀態傳遞給幫手
如果有人有一個更好的答案,這是歡迎的。