embedded

embedded field type is used to edit documents that are embedded into currently edited document (embedded_in and embeds_many relation) or are related to currently edited document (belongs_to and has_many relation). Embedded field editing is done by loading edit form for embedded collection into iframe.

 

The downside is that user has another set of actions painted on input FORM and must take care which ''Save'' button to choose to save data. 


Forms can be embedded as many levels as MongoDB can provide. DcMenu object is an example of such data input.

 

name: dc_poll_items
form_name: dc_poll_item
type: embedded
load: delay
html:
  height: 800 

 

Since embedded field data is loaded into iframe, load option controls when iframe data is refreshed. 

  - default, when parent form is loaded

  - delay, when tab containing embedded field is selected

  - always, whenever tab containing embedded field is clicked 

 

The above example is for editing embedded documents when dc_poll_items are embedded into dc_poll document and are edited by dc_poll_item form.

 

Example below would be used if dc_poll_items are saved to different collection. In this case field name and form_name must be the same value.

 

name: dc_poll_item
form_name: dc_poll_item
type: embedded
html:
  height: 800

 

Related document must contain id of parent document, therefore little piece of code must be written to ensure this. The code below must be putted into controls file in our example dc_poll_item_control.rb

 

module DcPollItemControl

def dc_new_record
  @record.dc_poll_id = params[:ids]
end

end

 

 


Last update: 07.02.2021