Is there some working solution that i can see on github?
I want to have a "Person" content-type with two separate fields (name and surname) that will generate both title and id.
I'm trying @spereverde solution but i can't save my new content.
I have a content-type like this:
@implementer(IPerson, INameFromTitle)
class Person(Container):
""" custom ct"""
@property
def title(self):
if hasattr(self, "name") and hasattr(self, "surname"):
return self.name + " " + self.surname
else:
return ""
Then i:
- added title (not a required field, need to hide it later), name and surname fields in its schema
- disabled plone.basic behavior and keep plone.namefromtitle (to not have the title required field)
But when i try to save the content, i have this traceback:
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 371, in publish_module
Module ZPublisher.WSGIPublisher, line 266, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 63, in call_object
Module plone.z3cform.layout, line 63, in __call__
Module plone.z3cform.layout, line 47, in update
Module plone.dexterity.browser.add, line 138, in update
Module plone.z3cform.fieldsets.extensible, line 65, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 145, in update
Module plone.app.z3cform.csrf, line 22, in execute
Module z3c.form.action, line 98, in execute
Module z3c.form.button, line 315, in __call__
Module z3c.form.button, line 170, in __call__
Module plone.dexterity.browser.add, line 116, in handleAdd
Module z3c.form.form, line 263, in createAndAdd
Module plone.dexterity.browser.add, line 67, in create
Module zope.component._api, line 224, in createObject
Module plone.dexterity.factory, line 40, in __call__
Module plone.dexterity.content, line 763, in __init__
Module plone.folder.ordered, line 249, in __init__
Module Products.CMFCore.PortalFolder, line 77, in __init__
AttributeError: can't set attribute
Same error with the solution from the blogpost.
If i remove the "def title", saving process ends succesfully.
I'm sure that I'm missing something really stupid but I can't see it 