[ZPT] tal path thingies
Tom Deprez
Tom Deprez" <tom.deprez@uz.kuleuven.ac.be
Wed, 13 Mar 2002 18:01:44 +0100
Hi,
I'm trying to insert data from a database inside Formulator and I'm almost
there (probably not the best way, but hey I'm learning :-)), but I'm having
problems. Here is my code. Please remove or improve it if you are able to!
<span tal:define="item container/sql_getEquipmentById">
<form action="." method="POST">
<table border="0">
<tr tal:repeat="field here/form/get_fields">
<td><strong
tal:content="python:field.get_value('title')">Title</strong>
<span
tal:condition="python:field.is_required()">*</span></td>
<td tal:define="fname
python:field.get_value('alternate_name');aValue
python:path('item[0]/%s'%fname);">
<input type="text" name="foo"
tal:replace="structure
python:field.render(aValue)" /></td>
<td><i
tal:content="python:field.get_value('description')">Description</i></td>
</tr>
<tr><td colspan="2"><input type="submit" value=" OK
"></td></tr>
</table>
</form>
</span>
So, it basically calls a zsqlmethod which will return one record, the
important part is:
<td tal:define="fname
python:field.get_value('alternate_name');aValue
python:path('item[0]/%s'%fname);">
I can show the value through <td tal:content="python:item[0].IPADDRESS">
but I want that 'IPADDRESS' is variable, depending on the Formulator field
I'm writing. I can get the 'IPADDRESS' part through
'python:field.get_value('alternate_name');'; but how do I then create the
path to item[0].IPADDRESS ?
And is there another way than just using item[0] ?
Thanks, Tom.
What I'm trying to do