Top options

DRG Form is text document written in YAML format. YAML is human friendly easy to read and update format. In YAML options can be nested simply by offsetting lines by blank space characters.

 

Simplest DRG form is shown below.

 

## Form for dc_manual settings
table: dc_memory
title: helpers.dc_manual.settings
  eval: Class.method_name
control: design_element_settings

form:
  actions:
    1: save

  fields:
    10:
      name: manual_id
      type: select
      text: helpers.dc_manual.drg_manual_id
      help: helpers.dc_manual.drg_manual_id_help
      eval: "dc_choices4('dc_manual','title')"

 

table: is required and defines table (collection) where entered data will be saved. Table option is written in snake_case. Collection name must be defined as a Mongoid class model (written in CamelCase). In our example DcMemory model defines special model which holds data in the memory.

 

title: Title of data input form. Title can also have a nested keyword eval: which would provide title dynamically.

 

control: Controls file which will be used for processing the form. Methods defined in controls file are included into cmsedit controller during action processing. By default controls file name is constructed from table name and string "_control".  For example dc_site collection will have dc_site_control file which implements DcSiteControl class.  

 

Controls (among other) may contain 6 fixed callback methods. These methods are:

  • dc_new_record
  • dc_before_edit
  • dc_before_save
  • dc_after_save
  • dc_before_delete
  • dc_after_delete

Methods dc_before_edit, before_save or before_delete may also effect flow of the application. If method return false (not nil but FalseClass) normal flow of the program is interrupted and last operation is canceled.

 

Control file may also implement the dc_before_form method. This method is called just after form has been read and before it is processed. Thus dynamic forms can be used in a program.

 

 


Last update: 04.01.2023