Extending the select widget-type
Archived from the Xataface Users forum.
prestoy — Mon Jan 22, 2007 8:32 am
I’ve been testing dataface and I’d like to give you lots of credit for this application. I’m already planning to implement a couple of databases in dataface.
But I miss one feature though, which for me will be a significant enhancement of dataface: I’d like to use a database table as the source for the select widget. When I’ve been designing web interfaces for databases I have many times used select-widgets like these:
Element A
Element B
Element C
Element D
Element E
Element F
The id-attr is a unique key in the source table, and the option text “Element “ is from another column in the table. Would you consider implementing a select-widget like this in the near future?
njw — Mon Jan 22, 2007 9:22 am
If I understand you right, this already exists. Have a look here, http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists , at Example 3.
Regards
Neil
prestoy — Tue Jan 23, 2007 5:46 am
If I understand you right, this already exists. Have a look here, [http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists](http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists) , at Example 3.
This is nearly the same thing, but with valuelists you define the select-values in fields.ini for the table. What I would like to see is a way to draw the valuelist from the contents of a table in the database. This table could be defined like this:
CREATE TABLE (
id INTEGER,
desc VARCHAR(100)
}
The the table content may be:
id desc
1 Element A
2 Element B
3 Element C
4 Element D
5 Element E
From this table you can make this select widget:
Element A
Element B
Element C
Element D
Element E
You could obviously skip the id attribute (and hence the id column) in the option tag if the contents of the desc column is unique. I hope I’ve provided a more understandable description of my wish now…
prestoy — Tue Jan 23, 2007 5:52 am
It seems that html code for the select widget doesn’t show as text even if it is in a pre-tag (see my last comment). Hope this is better:
Element A
Element B
Element C
Element D
Element E
shannah — Tue Jan 23, 2007 12:40 pm
Define your valuelist as follows:
[my_valuelist]
__sql__ = “select id,desc from my_table”
Then in your fields.ini file, define your field as follows:
[my_field]
widget:type = select
vocabulary = my_valuelist
This will give you a select list like you describe above.
-Steve