# `Doggo.Form`
[🔗](https://github.com/woylie/doggo/blob/0.18.4/lib/doggo/form.ex#L1)

Helpers for building custom form controls with the same ids and ARIA
attributes as the `field` component.

# `field_description_id`
*since 0.18.0* 

```elixir
@spec field_description_id(String.t()) :: String.t()
```

Returns the id of the description of the field with the given input id.

## Example

    iex> Doggo.Form.field_description_id("pet-name")
    "pet-name-description"

# `field_errors_id`
*since 0.18.0* 

```elixir
@spec field_errors_id(String.t()) :: String.t()
```

Returns the id of the error list of the field with the given input id.

## Example

    iex> Doggo.Form.field_errors_id("pet-name")
    "pet-name-errors"

# `input_aria_describedby`
*since 0.18.0* 

```elixir
@spec input_aria_describedby(String.t(), list(), list()) :: String.t() | nil
```

Returns the `aria-describedby` value of an input: the ids of the error list
and the description, if the field has them, or `nil`.

`description` and `errors` are lists, such as the entries of a description
slot and the error messages. The id of the error list comes first, as in the
markup of `field`.

The id of the error list is also the `aria-errormessage` value (see
`input_aria_errormessage/2`). It is included here as well, since screen
readers support `aria-errormessage` inconsistently.

## Examples

    iex> Doggo.Form.input_aria_describedby("pet-name", [], [])
    nil

    iex> Doggo.Form.input_aria_describedby("pet-name", [], ["is too short"])
    "pet-name-errors"

    iex> Doggo.Form.input_aria_describedby("pet-name", ["Your pet's name"], [])
    "pet-name-description"

    iex> Doggo.Form.input_aria_describedby(
    ...>   "pet-name",
    ...>   ["Your pet's name"],
    ...>   ["is too short"]
    ...> )
    "pet-name-errors pet-name-description"

# `input_aria_errormessage`
*since 0.18.0* 

```elixir
@spec input_aria_errormessage(String.t(), list()) :: String.t() | nil
```

Returns the `aria-errormessage` value of an input: the id of the error list
if there are errors, or `nil`.

## Example

    iex> Doggo.Form.input_aria_errormessage("pet-name", ["is too short"])
    "pet-name-errors"

# `translate_error`
*since 0.18.0* 

```elixir
@spec translate_error({String.t(), keyword()}) :: String.t()
```

Interpolates the values of an error into its message, without translating
it.

This is the default of the `translate_error` build option of `field`.

## Example

    iex> Doggo.Form.translate_error({"must have %{count} items", [count: 3]})
    "must have 3 items"

---

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