Mautic Community Forums

Where is the API "add custom field to contact" controller?

I’m trying to add custom fields programmatically with a custom plugin using API library (I was looking for pure programmatic insert method without success: add new custom field into lead table).

The API route /api/fields/contact/new it’s almost ok, but alias field, that’s is a key field, is limited to 26 chars and the insert truncate it, despite the db fields is varchar(255).
I’m trying to debug this insert in order to use more chars.

Someone knows which is the Controller for that url? Or know a solution in order to add custom fields programmatically managing all the necessary fields without this chars limit?

Mautic version is: 2.16.0
PHP version is: php72-fpm

Thanks in advance.

Ok, I’ve found the Controller:


It makes a form submission but I haven’t found where the process truncate alias string to 25 chars, even if I’ve changed (to test the submission) the value from 25 to 100 in his template:

app/bundles/LeadBundle/Form/Type/FieldType.php: line 450

How to remove this limit?

Thank you.

I think need to update