Posts tagged 'fields'

Checking Plone REQUEST for Ajax’d requests (XMLHttpRequest)

Recently, I’ve needed a PloneFormGen (PFG) form of mine to have certain fields excluded when the form is displayed in one of Plone 4’s fancy popups.  At the same time, I need this field to still persist within the ‘standard’ view of the form.  It’s the request object to the rescue, and all I’ve had to do is insert this TALES expression against the Enabling Expression for my PFG field:

python:request.environ.get('HTTP_X_REQUESTED_WITH') != 'XMLHttpRequest'

and the end result is that unless the request is one of XMLHttpRequest, then we’ll show the field.

Shouldn …

Plone, Dexterity, and Incorrect Widgets

A nice ‘gotcha’ is the distinction between Zope’s schema.Date and schema.Datetime. The difference is obvious and straightforward when the two terms are laid out side-by-side: one is for dates only and the other adds a time component. Where things fell down for me in my usage of these fields with a Dexterity-based content type in Plone is the human component. When these fields are mashed in together within a lot of other text/Python/names, it’s easy to miss those 4 little letters of ‘time’. This lead me trying to use a DatetimeFieldWidget when I really …