Plone 4.3 Dexterity contenttypes: change field from schema.Choice to schema.List

Has anyone had success with creating a custom (Dexterity) contenttype, and then after data has been entered for a field, changing its type from Choice to List?

For example, here is the original custom field, created as a single select Choice field, using a vocabulary that populates the dropdown choices:
personRole = schema.Choice(
title=(u"Role"),
description=
(u"Role of person in the Technical Standards Program"),
vocabulary=('TSP.Type.PersonRole'),
required = True
)

Now, it needs to change to a multi-select checkbox field. Here is what I changed it to:
form.widget(personRole=CheckBoxFieldWidget)
personRole = schema.List(
title=(u"Role"),
description=
(u"Role of person in the Technical Standards Program"),
value_type=schema.Choice(vocabulary='TSP.Type.PersonRole'),
required = True
)

The Problem: now the edit form will not populate the existing data into the checkboxes.

If you have a live database that needs to be preserved you need to write an
upgrade step
https://docs.plone.org/develop/addons/components/genericsetup.html#upgrade-steps
to change the existing objects to a list.

2 Likes

Thank you very much for your suggestion. This solved my data problem.
cheers!

Plone Foundation Code of Conduct