@@ -19,7 +19,7 @@ The easiest way to show how this plugin works is looking the examples [below](#e
1919
2020## Options
2121
22- Options are passed to fields using * input_html* parameter:
22+ Options are passed to fields using * input_html* parameter as * data * attributes :
2323
2424- ** data-if** : check a condition, values:
2525 + ** checked** : check if a checkbox is checked
@@ -34,6 +34,7 @@ Options are passed to fields using *input_html* parameter:
3434 + ** hide** : hides elements
3535 + ** slide** : hides elements (using sliding)
3636 + ** fade** : hides elements (using fading)
37+ + ** addClass** : adds classes
3738 + ** setValue** : set a value
3839 + ** callback** : call a function
3940- ** data-value** : value to set
@@ -47,15 +48,19 @@ Options are passed to fields using *input_html* parameter:
4748``` rb
4849form do |f |
4950 f.inputs ' Article' do
50- f.input :published , input_html: { ' data-if ' : ' not_checked' , ' data- action' : ' hide' , ' data- target' : ' .grp1' }
51+ f.input :published , input_html: { data: { if : ' not_checked' , action: ' hide' , target: ' .grp1' } }
5152 f.input :online_date , wrapper_html: { class : ' grp1' }
5253 f.input :position , wrapper_html: { class : ' grp1' }
5354 end
5455 f.actions
5556end
5657```
5758
58- - Set another field value if a string field is blank:
59+ - Add 3 classes (* first* , * second* , * third* ) if a checkbox is true:
60+
61+ ` f.input :published, input_html: { data: { if: 'checked', action: 'addClass first second third', target: '.grp1' } } `
62+
63+ - Set another field value if a string field is blank (with alternative syntax for data attributes):
5964
6065` f.input :title, input_html: { 'data-if': 'blank', 'data-action': 'setValue', 'data-target': '#article_position', 'data-value': '10' } `
6166
0 commit comments