this not runs . Field('materials', 'list:string','reference malzemeler')

46 views
Skip to first unread message

Mustafa Yalçın

unread,
Oct 5, 2021, 9:49:20 AM10/5/21
to web2py-users
hi everyone,

 i have encountred a problem.

as you see a field below, I want to add more rows to materials and I want to add a dropdown box to each added row.

 

Field('materials', 'list:string','reference malzemeler'),


these codes not run. Also I am using  SQLFORM.grid.

i want to add rows (using + and - buttons). 'list:string' make this.

also , i want to add drop down box  to these rows. 

could you help please.

materials add and dropdownbox.png

Massimo Di Pierro

unread,
Oct 6, 2021, 1:34:52 AM10/6/21
to web2py-users
Hello Cassio,

the Field constructor takes a name and a type. The type can be "list:reference malzemeler" (assuming you have a table malzemler). Also if you want the value to display something other than the id of a referenced record, you have to specify a record format for the referenced table. In your case for example db.define_table("malzemler", Field("name"), format="%(name)s").

If you want dropdowns in multi-lists you may want to consider using requires=IS_IN_DB(db, table.id, table.namefield, multiple=True) and use something like http://www.web2pyslices.com/slice/show/1395/jquery-multi-select-widget

Notice that all of this is very old. If you need a complex interface I would highly recommend using Vue.js and create your own UI and use py4web for backend api. That will work much better and be more customizable.

Massimo
Reply all
Reply to author
Forward
0 new messages