269
269
If the field is optional, a "Remove" link is shown. The "Remove" text is
270
270
customizable thought the "remove_button_text" parameter.
276
This widget provides a simple popup with two options for the user to choose
279
>>> from lp.app.browser.lazrjs import BooleanChoiceWidget
281
As with the other widgets, this one requires a context object and a Bool type
282
field. The rendering of the widget hooks up to the lazr ChoiceSource with the
283
standard patch plugin.
285
The surrounding tag is customisable, and a prefix may be given. The prefix is
286
passed through to the ChoiceSource and is rendered as part of the widget, but
287
isn't updated when the value changes.
289
If the user does not have edit rights, the widget just renders the text based
290
on the current value of the field on the object:
293
>>> from lp.registry.interfaces.person import IPerson
294
>>> hide_email = IPerson['hide_email_addresses']
295
>>> widget = BooleanChoiceWidget(
296
... eric, hide_email, 'span',
297
... false_text="Don't hide it",
298
... true_text="Keep it secret",
299
... prefix="My email: ")
301
<span id="edit-hide_email_addresses">
302
My email: <span class="value">Don't hide it</span>
305
If the user has edit rights, an edit icon is rendered and some javascript is
306
rendered to hook up the widget.
308
>>> login_person(eric)
310
<span id="edit-hide_email_addresses">
311
My email: <span class="value">Don't hide it</span>
314
<a class="editicon sprite edit"
315
href="http://launchpad.dev/~eric/+edit"></a>
319
LPS.use('lp.app.choice', function(Y) {
324
Changing the edit link
325
**********************
327
The edit link can be changed in exactly the same way as for the
328
TextLineEditorWidget above.