Jorge Godoy wrote:
>jose <[EMAIL PROTECTED]> writes:
>
>
>
>>I have a CalendarDatePicker field in a form that I want to be disabled
>>in certain conditions.
>>I tried to put this definition into attrs={'disabled':True} and infact
>>the text field results disabled but the choose_button remains enabled
>>all the way (I supposed it was disabled like the text field), infact if
>>I click it I can change the values in the text field.
>>Is there a way to disabled or remove such button?
>>
>>
>
>You can change the template and add the correct attribute to the button. If
>you do that and send a patch we can apply it to the code...
>
>
>
I don't know if this is the best way to do that, but it works for me.
I changed the template and the update_params function.
and this is how it works:
When you want to disable the textField and also the button, use:
attrs = {'disabled':True}
When you want remove the button, use:
button_text = None,
or both of them, to disable the textField and to remove button:
attrs = {'disabled':True},
button_text = None
-----------------------------------------------------------------------------------------
template = """
<div xmlns:py="http://purl.org/kid/ns#">
<input type="text" id="${field_id}" class="${field_class}"
name="${name}" value="${strdate}" py:attrs="attrs"/>
> <span py:if="button_text">
> <input type="button" id="${field_id}_trigger"
class="date_field_button" disabled="${disabled}" value="${button_text
> </span>
<script type="text/javascript">
Calendar.setup(
{
inputField : "${field_id}",
ifFormat : "${format}",
button : "${field_id}_trigger"
<span py:if="picker_shows_time" py:replace="', showsTime : true'" />
}
);
</script>
</div>
"""
----------
def update_params(self, d):
super(CalendarDatePicker, self).update_params(d)
> if self.attrs.get('disabled') == True:
> d['disabled'] = True
> else:
> d['disabled'] = None
if hasattr(d['value'], 'strftime'):
d['strdate'] = d['value'].strftime(d['format'])
else:
d['strdate'] = d['value']
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---