parent
63fb9a2773
commit
6eae2069dc
|
@ -1,6 +1,7 @@
|
|||
## master
|
||||
|
||||
### enhancements
|
||||
* Add support to html markup in the I18n options. [@laurocaetano](https://github.com/laurocaetano)
|
||||
* Add the `full_error` component. [@laurocaetano](https://github.com/laurocaetano)
|
||||
* Add support to `scope` to be used on associations. [@laurocaetano](https://github.com/laurocaetano)
|
||||
* Execute the association `condition` in the object context. [@laurocaetano](https://github.com/laurocaetano)
|
||||
|
|
|
@ -100,7 +100,13 @@ module SimpleForm
|
|||
def translate_collection
|
||||
if translated_collection = translate_from_namespace(:options)
|
||||
@collection = collection.map do |key|
|
||||
[translated_collection[key] || key, key.to_s]
|
||||
html_key = "#{key}_html".to_sym
|
||||
|
||||
if translated_collection[html_key]
|
||||
[translated_collection[html_key].html_safe || key, key.to_s]
|
||||
else
|
||||
[translated_collection[key] || key, key.to_s]
|
||||
end
|
||||
end
|
||||
true
|
||||
end
|
||||
|
|
|
@ -92,6 +92,20 @@ class CollectionRadioButtonsInputTest < ActionView::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'input should do automatic collection translation and preserve html markup' do
|
||||
swap SimpleForm, boolean_style: :nested do
|
||||
store_translations(:en, simple_form: { options: { user: {
|
||||
gender: { male_html: '<strong>Male</strong>', female_html: '<strong>Female</strong>' }
|
||||
} } } ) do
|
||||
with_input_for @user, :gender, :radio_buttons, collection: [:male, :female]
|
||||
assert_select 'input[type=radio][value=male]'
|
||||
assert_select 'input[type=radio][value=female]'
|
||||
assert_select 'label[for=user_gender_male]', 'Male'
|
||||
assert_select 'label[for=user_gender_female]', 'Female'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test 'input should mark the current radio value by default' do
|
||||
@user.name = "Carlos"
|
||||
with_input_for @user, :name, :radio_buttons, collection: ['Jose', 'Carlos']
|
||||
|
|
Loading…
Reference in New Issue