> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply accessor to child items

> Applies another accessor to each child item matching the supplied pattern.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Applies another accessor to each child item matching the supplied pattern. Use this when your data contains a repeating list, such as the products in an order or the lines on an invoice, and you want to read values from every item the same way instead of pointing at each one by hand. It walks over every matching child, applies the way of reading data you choose to each one, and collects the results into a single set of values.

This documentation describes: [Schema](/schemas/accessor/children)

## Fields

<FormField property="accessor" label="Accessor" required diType="accessor">
  The way of reading values that gets applied to each matching child item. You pick another accessor here, and it runs once per child.
</FormField>

<FormField property="pattern" label="Pattern" uiPatterns="pattern">
  A dot-notated pattern that decides which child items to walk over. Use `*` to match every item in a list, for example `products.*` to walk every product. Leave it empty to walk all children. Each `*` becomes a numbered capture group (`$1`, `$2`, and so on) that you can reuse in the Replacement field.
</FormField>

<FormField property="replacement" label="Replacement">
  Renames the path each matched item is stored under in the result. Use `$1`, `$2`, and so on to reference the capture groups from the `*` marks in your pattern. Leave it empty to keep the original numbering.
</FormField>

<FormField property="keys" label="Keys">
  A list of keys that limits which values are kept from each matched item. Leave it empty to return everything the chosen accessor reads from each child.
</FormField>

## Sample data

| Field       | Value                         |
| ----------- | ----------------------------- |
| Accessor    | Pattern accessor matching `*` |
| Pattern     | `products.*`                  |
| Replacement | `product$1`                   |

Input:

```json theme={null}
{
    "products": [
        { "name": "Wool scarf", "sku": "A1" },
        { "name": "Leather belt", "sku": "B2" }
    ]
}
```

Output:

```json theme={null}
{
    "name": {
        "product0": "Wool scarf",
        "product1": "Leather belt"
    },
    "sku": {
        "product0": "A1",
        "product1": "B2"
    }
}
```

```json Configuration theme={null}
{
  "prototype": "children",
  "parameters": {
    "accessor": {
      "prototype": "pattern",
      "parameters": { "pattern": "*" }
    },
    "pattern": "products.*",
    "replacement": "product$1"
  }
}
```
