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.

Custom ui:widget will not alter the formData

See original GitHub issue

Prerequisites

Description

When using ui:widget the field will not change the formData of the form, unlike when not using ui:widget any change in the field will be seen in the formData when the form is submitted.

Suggested solution:

Shall I change the formData of the form manually when the field text changes? if so, is there an example to do so?

Steps to Reproduce

  1. Create the class that represent the custom UI, and use the following for render:
return (
      <div >
      {this.props.children}   
      </div>
    )
  1. Add to the schema.properties "City": {type: "string", title:"City"}
  2. Add to the schema.properties "City": { "ui:widget": DefaultInput, classNames: "col-md-4"}

Where City is the name of the custom component. and DefaultInput is the class that represent the custom ui of field.

Expected behavior

To see the value of the custom text field when submit the form:

onSubmit = ({formData}) => console.log(formData);

Actual behavior

What I see is:

{City: undefined}

Version

1.1.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MatejBranskycommented, Aug 27, 2018

You must keep the same type of value. Because if you firstly render this widget (I suppose that you use <input>) without the default value then actual value will be undefined or null and later if you type something into the input then it will be a string and React doesn’t like switching the types. If you look into the BaseInput.js you can see that there is condition which sets the null value to the string "".

related SO

0reactions
epicfaacecommented, Dec 27, 2019

@akedar21 can you make a new issue with a codepen link so it’s easy to reproduce?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom ui:widget will not alter the formData - Stack Overflow
if you use custom 'ui:widgets' you have to use the json-schema-form onChange method when any item's value gets changed and after that you ......
Read more >
Advanced customization - React Jsonschema form
The following props are passed to a custom field template component: id : The id of the field in the hierarchy. You can...
Read more >
Advanced Form - inmation Docs!
Change Request for „UI Schema“ ; ui:widget. This property is used to select the specific widget to use as the input control for...
Read more >
react-jsonschema-form-semantic - npm
There are no other projects in the npm registry using ... The uiSchema ui:widget property tells the form which UI widget should be...
Read more >
Capture Form Data - Appsmith
Multiple widgets can be dragged inside the form widget to capture data. ... Any of the required fields inside the form are not...
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