# swap

> This document is the Markdown version of [formisch.dev/methods/api/swap/](https://formisch.dev/methods/api/swap/). For the complete documentation index, see [llms.txt](https://formisch.dev/llms.txt).

Swaps two items in a field array at the specified indices.

```ts
swap<TSchema, TFieldArrayPath>(form, config);
```

## Generics

- `TSchema` `extends FormSchema`
- `TFieldArrayPath` `extends RequiredPath`

## Parameters

- `form` `BaseFormStore<TSchema>`
- `config` `SwapConfig<TSchema, TFieldArrayPath>`

### Explanation

The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array and the two indices of the items to swap.

## Related

### Primitives

[`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md)

### Methods

[`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md)
