question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disabled Fields not getting initialValues; formatting does not work

See original GitHub issue

Hi, as I was using redux-form to create a connected component for my form. I struggled with the following 2 issues.

  1. Disabled Fields not getting initialValues In my form, I have
<Field
   name="abc"
   label="ABC"
   component={FormField}
   input={{
       disabled: true,
   }}
   required
/>

FormField takes input and add all the props to <input {...input}> However, no initial value is shown when the input field is disabled. When I took out the input disabled prop, the correct value shows up. From network response, I see that the value is there. It is just not getting displayed when the field is disabled for some reason.

  1. format I passed in both functions and anonymous arrow functions to the format prop but nothing worked, even when I had a dummy function that return a hard coded default value.
const formatField = (value, name) => {
     switch (name) {
        case '1':
             return 'something'
        case default:
             return 'default'
     }
}

or a simpler function format={(v) => v.toLocaleString('en')}

Thank you!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

2reactions
elhachimicommented, May 8, 2017

@hannahjin & @catsky had the same issue ended up using

   {disabled && <input {...input} placeholder={label} type={type} disabled/>}
   {!disabled && <input  {...input} placeholder={label} type={type} />}

inside renderInput and passed disabled as a prop in Field component

0reactions
lock[bot]commented, Oct 30, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

26129 (bound forms do not display disabled field initial values)
The subject pretty much says it all. If you create a form with an initial value for a disabled field, it displays fine...
Read more >
javascript - Ant Design component initialValue is not working ...
I have a modal which has a form inside of it. This modal is controlled by its parent. Its parent can open the...
Read more >
Final Form Docs – `FieldProps`
If true , the format function will only be called when the field is blurred. If false , format will be called on...
Read more >
lightning-record-edit-form - Salesforce Developers
The InformalName field is not supported for editing. For a list of supported objects, see the User Interface API Developer Guide. If you...
Read more >
Handling Forms - VeeValidate
This is because in most cases you don't need the model values until you ... sure the form is not submitted unless all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found