OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Is it possible for a controlled MUI TextField to return an object as value?

  • Thread starter Thread starter Louie
  • Start date Start date
L

Louie

Guest
I'm currently trying to build a custom input component based on the MUI TextField. The input is able to switch between languages so you can edit the value for multiple languages. The problem I'm facing is that I can just return the input string of the currently selected language when I submit the form. Is there a possibility to return an Object with the full state including all languages to my form?

Code example: https://playcode.io/1913099

So instead of returning

Code:
name: 'english value'

I want the form to return the full state of my input component like:

Code:
name: {
  en_EN: 'english value'
  de_DE: 'german value'
}

<p>I'm currently trying to build a custom input component based on the MUI TextField. The input is able to switch between languages so you can edit the value for multiple languages.
The problem I'm facing is that I can just return the input string of the currently selected language when I submit the form. Is there a possibility to return an Object with the full state including all languages to my form?</p>
<p>Code example:
<a href="https://playcode.io/1913099" rel="nofollow noreferrer">https://playcode.io/1913099</a></p>
<p>So instead of returning</p>
<pre><code>name: 'english value'
</code></pre>
<p>I want the form to return the full state of my input component like:</p>
<pre><code>name: {
en_EN: 'english value'
de_DE: 'german value'
}
</code></pre>
 
Top