Fork me on GitHub

select

An article by Gaspard Bucher

insert a menu selector

insert a menu selector

  • label (true, false, t, dyn str) prefix with a label field.
  • name to set a named node parameter (becomes node[xxx])
  • param to set raw parameter (not related to node[])
  • root_class class to list, incl. subclasses
  • without list of classes to omit (used with root_class)
  • nodes list of node ids or pseudo sql query
  • blank If “false” used with “nodes”, do not show blank field
  • values list of literal comma separated values
  • attr node or class attribute to select with selection (defaults to ‘id’ for Node and ‘name’ for class)
  • show node attribute to display (default: title), or values to display (when used with ‘values’)
  • tprefix prefix before translating values
  • tshow translated values to display
  • values list of values separated by commas
  • type (time_zone, profile)
  • selected Value to be selected (default). For params however, the current param value is used.
see input, label

select a value from a list

<r:select name='reason' values='failed,missed,sickness' selected='failed'/>

select a class

This is used when creating new objects.

<r:select name='klass' values='Project,Section' selected='Project'/>

select a parameter

This can be used to feed an ajax zone with a parameter (something that is not related to “node[]”).

<r:select param='rel' values='friend,husband,pet'/>

select the icon relation from a list of nodes

<r:select name='icon_id' nodes='images in project' selected='main.icon_id'/>

value translation

By default, literal values are translated by using the current dictionary with the ‘name’ or ‘param’ prefix. For example, an input field for “klass” with values “Post,Letter” would show the translations for “klass_Post” and “klass_Letter”. You can also set a specific prefix with “tprefix” or use tprefix='false' to not use a prefix.

<r:select name='klass' values='Post,Letter' tprefix='attr'/>

You can also specify each individual value to translate. This example would show options with value 1 showing as ‘english’, value 2 as ‘french’, etc.

<r:select name='foo' values='1,2,3' tshow='en,fr,de'/>

select a time zone

<r:select name='tz' type='time_zone'/>

select a profile

This is used when editing auth attributes (admin only) through the contact node (with pseudo StringHash parameter ‘auth’). The select options will list all the logins of profile users (is_profile = true).

<r:select name='auth[profile]' type='profile'/>

select some attribute value

You can use a query to get values and use them inside the select. This can be used to have some “templates” for letters or replies:

<r:select name='text' nodes='letter_templates in site' attr='text' show='title'/>

In case you want to copy more then just a field, you might want to have a look at the “copy_id” special attribute (not documented here yet, write an email to the mailing list).