# setValues()

Sets the values of the given fields.

This method is designed to update the fields values during the runtime without making the fields controlled explicitly. **You must not invoke `setValues()` on controlled fields.**

## Definition

```typescript
type SetValues = (fieldsDelta: FieldsDelta) => void

type FieldsDelta = {
  [fieldPath: string]: any | FieldsDelta,
}
```

## Example

Call the `formRef.setValues()` with the Object as its argument. Each key in that Object represents a field path, and each value either the next same Object, or the next value of the selected field.

```jsx
import React from 'react'
import { Form, Field } from 'react-advanced-form'
import { Input, Select } from 'react-advanced-form-addons'

export default class Example extends React.Component {
  handleCustomerTypeChange = () => {
    this.formRef.setValues({
      foo: 'another',
      primaryInfo: {
        firstName: 'John',
        lastName: 'Mavericl',
    })
  }
  
  render() {
    return (
      <Form ref={form => this.formRef = form}>
        <Select onChange={this.handleCustomerTypeChange}>
          <option value="b2c">Private</option>
          <option value="b2b">Business</option>
        </Select>
      
        <Input type="email" name="email" />
        <Input type="password" name="password" />
        
        <Field.Group name="primaryInfo">
          <Input name="firstName" />
          <Input name="lastName" />
        </Field.Group>
      </Form>
    )
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://redd.gitbook.io/react-advanced-form/components/form/methods/setvalues.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
