In zope-form format default value in field & and N
Up to General
Hi!
1) Opening a zope-form I need field fill with default values from Sql.
Make it so:
...
<dtml-in expr="RetrieveMaxEmployeePin_Code()" >
<input class="ControlsBold" id="pin_code" maxlength="4" size="4" value="<dtml-var MaxEmployeePin_Code missing='0001'>" name="pin_code">
</dtml-in>
...
where RetrieveMaxEmployeePin_Code is Z Sql Method returning 1 rows with MaxEmployeePin_Code column.
That works fine! But problem is that I need formatted value as "0017" but not just "17"
Wrote Python function
def f_PadlWith(S, ToLen, Char= ' ')
L= len(S)
ToLen= int(ToLen)
#print 'L:',L,' ToLen:::',ToLen
if ( L<= ToLen ):
Res= S
for I in range(L,ToLen):
Res= Char+Res
# print 'I:',I,' Res:::', Res
return Res
From ZMI it works fine! But I tried to use it in dtmp-expr. make so:
...
<dtml-in expr="RetrieveMaxEmployeePin_Code()" >
<input class="ControlsBold" id="pin_code" maxlength="4" size="4" value="<dtml-var " f_PadlWith(MaxEmployeePin_Code,4,'0')" missing='0001'>" name="pin_code">
</dtml-in>
...
and get error:
Error Type: TypeError
Error Value: len() of unsized object
...
As I understand first parameter for f_PadlWith is not string? That <dtml-var " f_PadlWith(MaxEmployeePin_Code,4,'0')"
is a wrong way? How is right?
2) I have field wich is defined as:
<tr class="Controls">
<th>Address2 :</th>
<td><input maxlength="50" size="50" value="<dtml-var address2 missing=''>" name="address2"></td>
</tr>
...
problem is that is in database that value is empty I see "None" though missing='' is defined. What is wrong?
with respect,
Nilov Serge.
1) Opening a zope-form I need field fill with default values from Sql.
Make it so:
...
<dtml-in expr="RetrieveMaxEmployeePin_Code()" >
<input class="ControlsBold" id="pin_code" maxlength="4" size="4" value="<dtml-var MaxEmployeePin_Code missing='0001'>" name="pin_code">
</dtml-in>
...
where RetrieveMaxEmployeePin_Code is Z Sql Method returning 1 rows with MaxEmployeePin_Code column.
That works fine! But problem is that I need formatted value as "0017" but not just "17"
Wrote Python function
def f_PadlWith(S, ToLen, Char= ' ')
L= len(S)
ToLen= int(ToLen)
#print 'L:',L,' ToLen:::',ToLen
if ( L<= ToLen ):
Res= S
for I in range(L,ToLen):
Res= Char+Res
# print 'I:',I,' Res:::', Res
return Res
From ZMI it works fine! But I tried to use it in dtmp-expr. make so:
...
<dtml-in expr="RetrieveMaxEmployeePin_Code()" >
<input class="ControlsBold" id="pin_code" maxlength="4" size="4" value="<dtml-var " f_PadlWith(MaxEmployeePin_Code,4,'0')" missing='0001'>" name="pin_code">
</dtml-in>
...
and get error:
Error Type: TypeError
Error Value: len() of unsized object
...
As I understand first parameter for f_PadlWith is not string? That <dtml-var " f_PadlWith(MaxEmployeePin_Code,4,'0')"
is a wrong way? How is right?
2) I have field wich is defined as:
<tr class="Controls">
<th>Address2 :</th>
<td><input maxlength="50" size="50" value="<dtml-var address2 missing=''>" name="address2"></td>
</tr>
...
problem is that is in database that value is empty I see "None" though missing='' is defined. What is wrong?
with respect,
Nilov Serge.
Powered by
Ploneboard
















