Details
-
Bug
-
Resolution: Invalid
-
Medium
-
3.2.2
-
None
Description
In documentation for fieldtype we uses the getFormFactory() in mapFieldValueForm() and mapFieldDefinitionForm()
I don't quite understand the comment "// Creating from FormBuilder as we need to add a DataTransformer.". No DataTransformer is added in that example.
If you need a data transformer, I think it is good practice to then add that in your FormType, in the buildForm() method. How to add a datatransformer seems to be missing from our documentation actually.
AFAIK, there is no benefits for doing that this complex, so we can just add the FormType as we do in the tutorial:
https://doc.ibexa.co/en/latest/tutorials/generic_field_type/6_settings/#define-field-type-format
https://doc.ibexa.co/en/latest/tutorials/generic_field_type/6_settings/#fielddefinitionformmapper-interface
In the special case where don't want to create your own FormType, but use a one of ours or Symfony's, and you need to use a datatransformer, then you may use the factory and addModelTransformer() here directly in mapFieldDefinitionForm() but the example in the doc does not do that.