> For the complete documentation index, see [llms.txt](https://klassdocs.gitbook.io/klassapp-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klassdocs.gitbook.io/klassapp-documentation/.design-sync/docs/formgroup.md).

# FormGroup

A labelled form control with error and help slots. Blade equivalent: `<x-form-group>` in `resources/views/components/form-group.blade.php`.

One component covers text, email, number, date, select and textarea — pick with `type`.

```jsx
<FormGroup label="Subject Name" name="name" type="text" required
           placeholder="e.g. Mathematics" />

<FormGroup label="Class" name="class_id" type="select" required
           placeholder="Select…"
           options={{ '4': 'Senior 1', '5': 'Senior 2' }} />

<FormGroup label="Admission Number" name="admission_no" type="text"
           error="That admission number is already taken." required />
```

## Props

* `label` — renders `<label for>`; the `for`/`id` is `name`, or a slug of the label when `name` is empty
* `type`: `text` (default) · `email` · `select` · `textarea` · `number` · `date`
* `options`: `{ value: label }` — select only
* `error` — adds `.ds-form-input-error` and renders `.ds-form-error` below
* `help` — renders `.ds-form-help` below
* `required` — adds the red asterisk (`.ds-form-label-required`) *and* the `required` attribute
* `children` — appended inside the wrapper, for a control the component doesn't cover

## Note on values

The Blade version reads `old($name, $value)` so it repopulates after a failed validation round-trip. The React port has no session, so `value` is the uncontrolled `defaultValue`. Wire it to real state in an app.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://klassdocs.gitbook.io/klassapp-documentation/.design-sync/docs/formgroup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
