Is there a way to add Fields to an Entity via the Entity Manager. I think i saw documentation about this somewhere. I can't seem to find it right now though. I could be mistaken as well.
Announcement
Collapse
No announcement yet.
Add Fields to an Entity in Code
Collapse
X
-
Hi m.mayer,
Hope, this thread will be helpful:
- Likes 1
-
If you are not familiar with the Entity Manager I recommend that you read this as well: https://docs.espocrm.com/administration/entity-manager/
- Likes 2
Comment
-
Sorry, i meant the Entity Manger in PHP Code. I am familiar with creating Fields in the GUI. I also know how to read and write data with the PHP Entity Manager. I had the impression there was a possibility to create Fields via PHP Code for a specific Entity.
I need to update the Fields of a specific Entity according to a third party API.
Comment
-
Hi m.mayer,
In this case, that article may come in handy:
Comment
-
I took a quick look into your suggested thread. It seems i could potentially create and alter Entity Field definitions by appending the metadata .json File. As i see it however there is no clean way of adding a Field to an Entity in PHP Code itself.
Ideally i am looking for something like this:
PHP Code:$entityManager = $this->getEntityManager();
$entityManager->getRepository($enitity)->addField("int", "counter", {options})
Comment
-
You can try to duplicate how fields are created in the Admin GUI, check this link https://github.com/espocrm/espocrm/b...eldManager.php
- Likes 1
Comment
-
strange request...
A database must be under control (security, integrity, conception, design,...).. i can't imagine give the opportunuity to a API to create field and so in database.
for me, you have :
if (!$entity->hasAttribute($value)) reject all ! create task and assign to someOne.
And what about rebuild ?
And what about reserved word .. in espoCRM, in database ..
And what about camelCase ?
it's just my opinionLast edited by item; 10-19-2021, 05:53 PM.
- Likes 2
Comment
Comment