fields
When data input fields are grouped on single area they are defined by fields option.
form:
fields:
10:name: name
type: text_field
All input fields are numbered, which has two advantages. It maintains order of fields on the form and can be easily removed or replaced by a program or by extending form.
name: defines name of the field defined in the model. Name can also be a virtual field not defined in the model. Virtual fields can be used to trigger some actions, but their value is not saved to database.
form:
fields:
25:name: _update_menu
type: check_box
help: helpers.help.dc_page._update_menu
caption: helpers.label.dc_page._update_menu
In the example, from dc_page form, if check_box field is checked, application will perform additional calculations in dc_after_save control callback and update menu.
Name can also specify any method defined in model. In that case model must implement two methods to save and to get data from database.
form:
fields:
25:
name: coord
type: text_field
######################
Class Spot field: coordinates, Array def coord coordinates.join(',') end def coord=(value) self.coordinates = value.chomp.split(',') end end
In the example coordinates are saved as array in database, but are entered as string separated by comma in input field
Some other options which can apply to most of the fields.
form:
fields:
25:name: field_name
type: text_field
help: Help text
label: Label
readonly: true
size: 20
line: top
group: 3
default: 60
or
default:
eval: "Time.now.beginning_of_year.strftime('%d.%m.%Y')"
help: defines text which is displayed when user hover over field label text. If help text contains dot, then actual text must be defined in localization files.
label: or caption: Text displayed before (or on top) of the data entry field. If label text contains dots then actual text must be defined in localization files.
readonly: With this option field is displayed on a form, but it's value won't be saved to database, if manipulated in pre record display controller callbacks.
size: Size of the field on form which is translated to html size parameter for the field.
line: top (bottom) will write horizontal line above (below) the field
group: will group (number) of fields in single row
default: default value of the field can also be set on the form