{% extends "docs.html" %} {% block docs_fragment %}
field(label="", n="serv_form", type=ft("string"))
argument n="serv_form"
is the name of the form. needed for ordering of the fields.
it is necessary and must match the name of the form.
argument type=ft("string")
to specify the type of the field(not really just to group related properties together).
use of string not python names to make it variable and possibly configurable. if not specified it defaults to ft("string")
.
arguments to the field type might be passed like these: type=ft("string")(maxlen=50,minlen=None)
a sample form declaration:
serv_form = {
pnum = field(label="Port Number", n="serv_form", type=ft("int"),
sname = field(label="Service Name", n="serv_form",
type=ft("string")(maxlen=50,minlen=None),
}
the form declaration above describes the fields of the forms. the creation of the form is done using former
from the forms
module
serv_form = former(serv_form, {n='serv_form', })
add_field
.:
add_field(serv_form, {"addr_range": field(label="Address Range",
n="serv_form",)})
for defaults, pass a deffunc
argument to the former
.:
serv_form = former(serv_form, {n='serv_form'}, deffunc=c)
c is a callabled object e.g any function