(<id> )
(idForm Entity Cho Var Cls Able Del Lst . Prg)
idForm
is used to display and edit objects in the system.
Here is an example from the demo application included with the PicoLisp
distribution, in item.l:
(menu ,"Item"
(idForm ,"Item" '(choItem) 'nr '+Item T '(may Delete) '((: nr) " -- " (: nm))
(<grid> 4
,"Number" NIL (gui '(+E/R +NumField) '(nr : home obj) 10) NIL
,"Description" NIL (gui '(+E/R +Cue +TextField) '(nm : home obj) ,"Item" 30) NIL
,"Supplier" (choCuSu 0)
(gui '(+E/R +Obj +TextField) '(sup : home obj) '(nm +CuSu) 30)
(gui '(+View +TextField) '(field -1 'obj 'ort) 30)
,"Inventory" NIL (gui '(+E/R +NumField) '(inv : home obj) 12)
(gui '(+View +NumField) '(cnt> (: home obj)) 12)
,"Price" NIL (gui '(+E/R +FixField) '(pr : home obj) 2 12) )
(--)
(<grid> 2
,"Memo" (gui '(+BlobField) '(txt : home obj) 60 8)
,"Picture"
(prog
(gui '(+Able +UpField) '(not (: home obj jpg)) 30)
(gui '(+Drop +Button) '(field -1)
'(if (: home obj jpg) ,"Uninstall" ,"Install")
'(cond
((: home obj jpg)
(ask ,"Uninstall Picture?"
(put!> (: home top 1 obj) 'jpg NIL) ) )
((: drop) (blob! (: home obj) 'jpg @)) ) ) ) )
(<spread> NIL (editButton T))
(gui '(+Upd +Img)
'(and (: home obj jpg) (allow (blob (: home obj) 'jpg)))
,"Picture" ) ) )
The first argument to idForm
is used to create a header, in our
case "Item". This is followed by 'choItem()
, which is a search
function. This allows us to use both search and edit functionality from the
same page. Then we have two arguments, 'nr '+Item
used to count
how many objects of a certain type is in the database. The T
argument that follows decides whether a user can edit objects in this form
or not. Next up is '(may Delete)
, checking if the current user
has permission to delete objects. Finally, the list '((: nr) "--" (:
nm))
is passed to the idForm
function. This is used to
create a heading that is displayed when a single object has been selected.
Our example will use the 'nr' and 'nm' properties of an +Item
object combined with " -- ". The result is something like this: "Item: 2 --
Spare Part".
+Icon
+Img
Alt
, Url
,
Dx
and Dy
.
(gui '(+Upd +Img)
'(and (: home obj jpg) (allow (blob (: home obj) 'jpg)))
,"Picture" "http://picolisp.com" 35 55) ) )
Alt
, Dx
and Dy
all set properties in
the resulting img tag:
<img src="..." alt="Picture" width="35" height="55 id=".." />
Adding a Url
argument turns the resulting image into a link:
<a href="http://picolisp.com"><img src="..." alt="Picture" width="35" height="55 id=".."/></a>
See also +gui and +Upd.
+Init
(gui '(+Init +TextField) "Initial value" 30)
+InsRowButton