<p>Is it possible to change behavior of in-built field with a module?
I am trying to change <code>// Apply static translations</code> part of <code>_normalizeValueInternal</code> function in Table.php
<a href="https://github.com/craftcms/cms/blob/5744e952204802a424abed96270ea52631cd61ea/src/fields/Table.php#L443" rel="nofollow noreferrer">https://github.com/craftcms/cms/blob/5744e952204802a424abed96270ea52631cd61ea/src/fields/Table.php#L443</a></p>
<p>I can make it work if I edit the core Table.php file, but that would be overwritten each update. So I am thinking about module.</p>
<p>I can only find guides to create new custom field, but nothing about changing built-in fields.</p>
<p>Thanks.</p>

CC BY-SA 4.0
2023-10-16T14:28:31.003Z
You can't really modify the internal logic of fields, you can only modify the business logic using event hooks, or extend a built-in field to modify it as needed. What problem are you trying to solve?l
MoritzLost
CC BY-SA 4.0
2023-10-16T14:43:53.710Z
As described here https://github.com/craftcms/cms/discussions/13703#discussioncomment-7282636
I am trying to change target language of static translation of Row Headings in Table field in backend. So instead of CP language it's determined by site language. In linked comment there is also code that would need to be changed. It's just "good to have" nothing critical.
Foxtrot
CC BY-SA 4.0
2023-10-16T15:39:26.030Z
Hm, looks tricky. Not sure if there's an easy way to change that behaviour without extending the field. Might be able to overwrite the labels using JavaScript, though that's not a great solution either.
MoritzLost
CC BY-SA 4.0
2023-10-16T17:58:56.023Z
Maybe try to make custom field that extends table field class? Your class could overwrite method that contains piece of logic that you want to change. After you create new class you would only need to register it (you can check field plugins to find how they register their own fields) so it is selectable as field type.
Piotr Pogorzelski
CC BY-SA 4.0
2023-10-17T09:53:50.880Z
Yeah, I know I can make custom field that extends the built-in field. That's why I am asking if it's possible to directly change built-in field or if custom field is the only option. But it looks like there is no easy direct way to do it without making custom field. Thanks for answers.
Foxtrot
<field><modules>
Is it possible to change built-in field like Table with a module?
# Is it possible to change built-in field like Table with a module?

(Asked by: username_0 on 2023-10-16)

Is it possible to change behavior of in-built field with a module?
I am trying to change `// Apply static translations` part of `_normalizeValueInternal` function in Table.php
<https://github.com/craftcms/cms/blob/5744e952204802a424abed96270ea52631cd61ea/src/fields/Table.php#L443>

I can make it work if I edit the core Table.php file, but that would be overwritten each update. So I am thinking about module.

I can only find guides to create new custom field, but nothing about changing built-in fields.

Thanks.

**Tags:** field, modules

> **Comments:**
> **username_1**: You can't really modify the internal logic of fields, you can only modify the business logic using event hooks, or extend a built-in field to modify it as needed. What problem are you trying to solve?l  
> **username_0**: As described here https://github.com/craftcms/cms/discussions/13703#discussioncomment-7282636 I am trying to change target language of static translation of Row Headings in Table field in backend. So instead of CP language it's determined by site language. In linked comment there is also code that would need to be changed. It's just "good to have" nothing critical.  
> **username_1**: Hm, looks tricky. Not sure if there's an easy way to change that behaviour without extending the field. Might be able to overwrite the labels using JavaScript, though that's not a great solution either.  
> **username_2**: Maybe try to make custom field that extends table field class? Your class could overwrite method that contains piece of logic that you want to change. After you create new class you would only need to register it (you can check field plugins to find how they register their own fields) so it is selectable as field type.  
> **username_0**: Yeah, I know I can make custom field that extends the built-in field. That's why I am asking if it's possible to directly change built-in field or if custom field is the only option. But it looks like there is no easy direct way to do it without making custom field. Thanks for answers.  

---

## 0 answers

