Skip to content

Show Catalogs Catalogs in Forms

andreasknoepfle edited this page Sep 14, 2010 · 4 revisions

Show Trees

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 ?

Radio Trees

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.

Checkbox Trees

Same usage as radio trees (But no preselection of nodes!!!). The result is presented as a comma seperated list of node_ids.
= checkbox_tree @catalog, 'the_id_of_your_form' , 'the_param_key_you_want_to_use'