Topic: Autocomplete - React

roshanpr pro asked 5 years ago


Hi there, I am using controlled forms in react and the way to have my formData filled up is by passing forData fields as "value" to the input field. Correspondingly, my handleFormData looks up an event by "name". This works fine for a regular Input field. However, for the Autocomplete, am unable to get the value in the handleFormData by "name". Any suggestions? <div className='form-group'> <Input name='contact_streetaddress' label='Current Home Address' type='textarea' rows='2' className="mt-4" autoFocus={this.calculateAutofocus(1)} icon="home" group value={this.state.formData.contact_streetaddress} validate required onChange={this.handleFormChange} /> </div> <div className='form-group'> <Autocomplete icon='globe' label="Your country" className="mt-4" clear data={countries} clearClass="grey-text" inputprops={{value:this.state.formData.contact_homecountry, onChange:this.handleFormChange}} /> </div>

handleFormChange(event){
    const obj =this.state.formData
    obj[event.target.name] = event.target.value
    this.setState(obj)
    console.log(this.state.formData)
  }

Jakub Strebeyko staff answered 5 years ago


Hi there, There is no easy way to get the value until tomorrow's update, where Autosuggest will get a getValue function prop. Stay tuned! Best, Kuba

innovative23 pro commented 5 years ago

Any update?

Mikołaj Smoleński staff commented 5 years ago

You are now able to get values from autocomplete by using 'getValue' function prop. Best Regards


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No
Tags