php - TYPO3: Save and edit the first & last name of an FE user
I created an extension with the extension builder which extends the FE user model.
To access the fields, I added the properties inside the extension builder accordingly. This worked great withcity
,zip
,address
etc. Unfortunately, you can't enter underscores, so I couldn't addfirst_name
andlast_name
to the properties. I addedfname
andlname
(inside the ext. builder) instead and renamed everyfname
andlname
tofirst_name
andlast_name
by hand (inside the code).
I hope you could follow me until now.
Because the problem is, when adding a FE user through the new action in the frontend, the first and last name won't be saved. But you can save them without a problem in the backend.
Any ideas how to fix that?
Answer
Solution:
Use the extbase conventions for field names (lower camel case in model classes, e.g.
$firstName
and$lastName
). If you do this, they will automatically mapped to the database fieldsfirst_name
andlast_name
, which is also the reason for the restriction in theextension_builder
. If you don't want to do this, you have to configure the mapping of field name to database field manually in your TypoScript configuration.Alternatively, you can just use the properties and accessor methods provided by the extbase
FrontendUser
model, from which you inherit - no need to implement that stuff yourself.