[Twisted-Python] Generate select options in woven
Samuel Reynolds
sam at SpinwardStars.com
Mon Dec 8 10:51:07 EST 2003
That helps a lot. Thanks.
However...
Is it possible to get
<option value='id1'>label1</option>
?
So that
wmfactory_versions = {
{val='id1', desc='value1'},
{val='id2', desc='value2'},
{val='id3', desc='value3'} }
or (preferably)
wmfactory_versions = {'id1':'value1','id2':'value2','id3':'value3'}
and
<select name='display' model='versions' view='[[SOMETHING?]]'>
[[SOMETHING?]]
</select>
yield
<select name='display>
<option value='id1'>value1</option>
<option value='id2'>value2</option>
<option value='id3'>value3</option>
</select>
I've tried several variations of view='List' and view='KeyedList'
on the select tag, using the above models, without success.
The nearest I've been able to get is one of the following:
<option value='id1'>id1</option>
<option value='value1'>value1</option>
<option value='id1'>value1id1</option>
- Sam
At 2003-12-08 07:53 AM +0100, you wrote:
>On Sunday 07 December 2003 21:02, Samuel Reynolds wrote:
> > Can someone help me out? I'm trying (so far without success) to get Woven
> > to generate the Options for a Select from my Model. I haven't found any
> > docs or examples that explain it.
>
>You can use something like this :
>
><select name="display" onChange="submit()" model="versions" view="List">
> <span pattern="listItem">
> <option view="display_value" value="thevalue"><span
> view="Text"></span>
> </option>
> </span>
></select>
>
>
>here is your simple model
>
>def wmfactory_versions(self, request):
> return ["item1", "item2", "item3"]
>
>
>This will help to autoselect the last selected value :
>
>from twisted.web import microdom
>
>def wvupdate_display_value(self, request, node, model):
> option = microdom.lmx(node)
> option['value'] = model
> display = request.args.get("display", [""])[0]
> if display == model:
> option['selected'] = "1"
>
>I hope this helps !
>
>
>Regards
>--
>Philippe
>
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list