[Zope3-dev] enahnced widget usecase
Garrett Smith
garrett at mojave-corp.com
Fri Oct 1 10:47:27 EDT 2004
dev at projekt01.ch wrote:
> Garrett Smith wrote:
>> Betreff: RE: [Zope3-dev] enahnced widget usecase
>>
>>
>> dev at projekt01.ch wrote:
>>> Hi together,
>>>
>>> How can I handle this widget usecase:
>>>
>>> A object has simply IText fields like:
>>>
>>> title, description, body
>>>
>>> I whould like to show a edit view where
>>> the field title and description displayed but
>>> not editable and the body field is rendered
>>> with his relevant edit widget.
>>
>> The simplest way is to define two attributes in your view class:
>>
>> title_widget = CustomWidgetFactory(DisplayWidget)
>> description_widget = CustomWidgetFactory(DisplayWidget)
>>
>> You could adapt the context to a schema that had readonly
>> title and description fields, but this is a lot more work
>> than explicitly specifying the widget classes to use, per the
>> example above.
>>
>> -- Garrett
>
> Yes I know, sorry, my description of the usecase was
> unclear.
>
> Correct usecase
>
> The user should be able to use a display view where
> he can click on a icon next to a field and this whould
> return the view with the selected field editable.
> All other fields are in the display mode.
As you said, you'd make the use of display widgets conditional -- I'd
move the widget definition into the view's __init__ method...roughly:
def __init__(self, context, request):
...
for each field in self.schema:
if not request.get('%s.icon_clicked' % field):
setattr(self, '%s_widget' % field,
CustomWidgetFactory(DisplayWidget))
Sounds like you have a solid understanding of what you need to do.
-- Garrett
More information about the Zope3-dev
mailing list