-
Notifications
You must be signed in to change notification settings - Fork 3
Show Catalogs Catalogs in Forms
andreasknoepfle edited this page Sep 14, 2010
·
4 revisions
To show a catalog as ajax tree simply use show_catalog method with the catalog object you want to show:
Haml:
= show_tree @catalog
Simple. Huh ?
To get a Tree with radio-button acting checkboxes you can use:
Haml:
= radio_tree @catalog, 'the_id_of_your_form' , 'the_param_key_you_want_to_use', [ selected_entry_id ]
- The second parameter should contain the html id of the form.
Hint:
If you don’t know how to specify a forms id parameter with forms helpers use:
form_for/semantic_form_for ... ,:html => { :id => 'the_id_to_use' }
- The third parameter is the name of the resulting param key. Just specify a name that is not used as html id or html input name
- The last parameter is optional. It sets a entry preselection that is loaded with the tree! Just hand over the id of the entry you want to preselect.
Same usage as radio trees. The result is presented as a comma seperated list of node_ids. Optional an array of selected nodes for preselection can be passed.
= checkbox_tree @catalog, 'the_id_of_your_form' , 'the_param_key_you_want_to_use' , [ array_of_selected_node_ids ]