i have a button and i wanted it to enable or
disable with respect to a python variable.
code:
<?python
if usr_rght in user_rights: //usr_rght is an
integer and user_rights is a list//
add_user = "false"
else:
add_user = "true"
?>
<input type="button" value="ADD USER" disabled="${add_user}" />
when i use simply ${add_user} it prints-------------- false
If you can avoid <? snippers, please do yourself a favour.
> <input type="button" value="ADD USER" disabled="${add_user}" />
>
> when i use simply ${add_user} it prints-------------- false
>
You must user None if you don't want to render the attribute.
With python 2.5:
<input type="button" value="ADD USER" disabled="${None if usr_rght in
user_rights else 'DISABLED'}" />
With python 2.3-2.4:
<input type="button" value="ADD USER"
disabled="${['DISABLED',None][usr_rght in user_rights]}" />
or
<input type="button" value="ADD USER" disabled="${usr_rght not in
user_rights and 'DISABLED' or None}" />