# Array

The `Array` field in allows you to display and manage structured array data. This field supports flexibility in fetching and rendering data, making it suitable for various use cases.

:::tip Important
To use the `Array` field, you must create a resource specifically for it. Refer to the Array Resource documentation for detailed instructions.

For example, to use `field :attendees, as: :array`, you can generate an array resource by running the following command:

```bash
rails generate avo:resource Attendee --array
```

This step ensures the proper setup of your array field within the Avo framework.
:::

### Example 1: Array field with a block

You can define array data directly within a block. This is useful for static or pre-configured data:

```ruby{3-8}
class Avo::Resources::Course < Avo::BaseResource
  def fields
    field :attendees, as: :array do
      [
        { id: 1, name: "John Doe", role: "Software Developer", organization: "TechCorp" },
        { id: 2, name: "Jane Smith", role: "Data Scientist", organization: "DataPros" }
      ]
    end
  end
end
```

:::warning Authorization
The `array` field internally inherits many behaviors from `has_many`, including authorization. If you are using authorization and the array field is not rendering, it is most likely not authorized.

To explicitly authorize it, define the following method in the resource's policy:

```ruby{3}