FORM

INTRO

The forms module provides AST transform of FORM document model into NITRO element model (second layer) which later will be transformed into HTML5 encoding (first layer).

CALLBACK API

The FORMS module expects forms to expose the following API.

Module:id() -> tuple().

Should return the default business object instance for this document form.

id() -> #'Document'{}.

Module:new(Name :: string(), BusinessObject :: tuple(), Options :: list({ atom(), term() })) -> element().

Should return the document form model by a given business object.

The standard set of options, provided with form base library:

  • {edit,true} — form for editing purposes.
  • {new,true} — form for document creation purposes.
  • {view,true} — form for document read only view mode.
  • {search,true} — form for document search purposes with disabled validators.
  • {row,true} — form for document row representation inside a table view.
new(Name,Object,Options) -> #'div'{id=Name,body=io_lib:format("~tp",[Object,Options])}.

Module:doc() -> binary() | list().

Retrieves the documentation string about this form module.

doc() -> "simple".

STATIC API

new(Form :: #document{}, BusinessObject :: tuple()) -> binary() | list().

Renders the form fullfilled with values from a given business object.

> :form.new(:form_ok.new("name",otp(),[]),otp()) {:panel, :element, 'ok_name', [], [], [], [], [], :form, [], [], [], [], [], [], [], [], [], [], [], [{:panel, :element, [], [], [], [], [], [], :caption, [], [], [], [], [], [], [], [], [], [], [], [{:h4, :element, [], [], [], [], ...}], [], ...}, {:panel, :element, [], [], [], [], [], [], :buttons, [], [], [], [], [], [], ...}], ...}
> :erlang.iolist_to_binary( :nitro.render( :form.new( :form_ok.new("name",otp(),[]),otp()))) "<div id=\"ok_name\" class=\"form\"><div class=\"caption\"><h4> Success Operation: CODE</h4></div><div class=\"buttons\"><a class=\"button sgreen\" id=\"auto-422845\" href=\"javascript:void(0);\">Confirm</a></div></div>"



This module may refer to: MAN_MODULES