# `Plato.Field`
[🔗](https://github.com/lassediercks/plato/blob/v0.0.24/lib/plato/field.ex#L1)

Field definition schema for content schemas.

Fields define the structure and type of data that can be stored in content instances.
Each field belongs to a schema and can have various types and options.

## Field Types

- `"text"` - Single-line or multiline text
- `"richtext"` - Rich text editor (future)
- `"reference"` - Reference to another content instance
- `"image"` - Image upload (requires S3 configuration)

## Field Options

Options are stored as a JSONB map and vary by field type:

### Text Fields
- `"multiline"` - Boolean, render as textarea instead of input

### Reference Fields
- Requires `referenced_schema_id` to be set

### Image Fields
- Requires S3 storage to be configured for the otp_app
- Will not appear in UI if storage is not configured

## Field Positioning

Fields have a `position` integer that determines their display order in forms.
Lower numbers appear first.

This module is primarily used internally. Use `Plato.SchemaBuilder` to define
fields in code, or the admin UI to create them interactively.

# `t`

```elixir
@type t() :: %Plato.Field{
  __meta__: term(),
  field_type: String.t(),
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  name: String.t(),
  options: map(),
  position: integer() | nil,
  referenced_schema: term(),
  referenced_schema_id: integer() | nil,
  schema: term(),
  schema_id: integer(),
  updated_at: DateTime.t() | nil
}
```

# `changeset`

Creates a changeset for a field.

Options:
  * `:otp_app` - The OTP app to check for storage configuration (required for image fields)
  * `:repo` - The Ecto repo to use for database operations (optional, derived from otp_app if not provided)

# `create`

```elixir
@spec create(map(), module(), keyword()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
