Skip to content

Commit

Permalink
Feature: add the 'prompt' attribute of the SequenceWidget to the list…
Browse files Browse the repository at this point in the history
… of adaptable attributes.
  • Loading branch information
Laurent Mignon authored and Laurent Mignon committed Dec 24, 2008
1 parent c74cc45 commit 05b349a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@ CHANGES

Version 2.0.0 (2008-??-??)
--------------------------
- Feature: add the 'prompt' attribute of the SequenceWidget to the list of
adaptable attributes.

- Fix: IMPORTANT - the signature of z3c.form.util.extractFileName function changed
because of spelling mistake fix in argument name. The ``allowEmtpyPostFix`` is
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/browser/select.py
Expand Up @@ -41,7 +41,7 @@ class SelectWidget(widget.HTMLSelectWidget, SequenceWidget):

# Internal attributes
_adapterValueAttributes = SequenceWidget._adapterValueAttributes + \
('noValueMessage', 'promptMessage')
('noValueMessage', 'promptMessage', 'prompt')

def isSelected(self, term):
return term.token in self.value
Expand Down
22 changes: 22 additions & 0 deletions src/z3c/form/browser/select.txt
Expand Up @@ -213,6 +213,28 @@ So after updating the widget you have the custom value:
>>> widget.promptMessage
u'please select a value'

Additionally, the select widget also allows dynamic value for the ``prompt``
attribute . Initially, value is ``False``:

>>> widget.prompt = False
>>> widget.prompt
False

Let's now register an attribute value:

>>> from z3c.form.widget import StaticWidgetAttribute
>>> AllowPrompt = StaticWidgetAttribute(True)

>>> import zope.component
>>> zope.component.provideAdapter(AllowPrompt, name='prompt')

After updating the widget, the value for the prompt attribute changed to the
value provided by the adapter:

>>> widget.update()
>>> widget.prompt
True

Display Widget
--------------

Expand Down

0 comments on commit 05b349a

Please sign in to comment.