PHPackages                             moonshine/layouts-field - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. moonshine/layouts-field

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

moonshine/layouts-field
=======================

Field for repeating groups of fields for MoonShine

3.1.0(3mo ago)108.5k↓33.4%5[1 issues](https://github.com/moonshine-software/layouts-field/issues)MITPHPPHP ^8.1|^8.2CI passing

Since Apr 12Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/moonshine-software/layouts-field)[ Packagist](https://packagist.org/packages/moonshine/layouts-field)[ Docs](https://moonshine-laravel.com)[ RSS](/packages/moonshine-layouts-field/feed)WikiDiscussions 3.x Synced 2d ago

READMEChangelog (10)Dependencies (8)Versions (25)Used By (0)

[![Layouts field for MoonShine](https://github.com/moonshine-software/moonshine/raw/2.x/art/lego.png)](https://github.com/moonshine-software/moonshine/raw/2.x/art/lego.png)
============================================================================================================================================================================

[](#)

Layouts field for MoonShine
---------------------------

[](#layouts-field-for-moonshine)

### Requirements

[](#requirements)

- MoonShine v4.0+

### Support MoonShine versions

[](#support-moonshine-versions)

MoonShineLayouts2.0+1.0+3.0+2.0+4.0+3.0+Quick start
-----------

[](#quick-start)

### Install

[](#install)

```
composer require moonshine/layouts-field
```

### Usage

[](#usage)

Field Layouts for MoonShine allows you to easily manage repeating groups of fields. You will be able to add, delete and sort groups consisting of basic fields. There are some restrictions on the use of fields in the Layouts field. You can use any basic fields except **Relationships** fields.

```
use MoonShine\Layouts\Fields\Layouts;

Layouts::make('Content')
    ->addLayout('Contact information', 'contacts', [
        Text::make('Name'),
        Email::make('Email'),
    ])
     ->addLayout('Banner section', 'banner', [
        Text::make('Title'),
        Image::make('Banner image', 'thumbnail'),
    ], validation: ['title' => 'required']),
```

#### Adding layouts

[](#adding-layouts)

Layouts can be added using the following method on your Layouts fields:

```
addLayout(
    string $title,
    string $name,
    iterable $fields,
    ?int $limit = null,
    iterable $headingAdditionalFields = null,
    array $validation = []
)
```

- `$title` - allows you to specify the name of a group of fields that will be displayed in the form,
- `$name` - used to store the chosen layout in the field's value,
- `$fields` - accepts an array of fields that will be used to populate a group of fields in the form,
- `$limit` - allows you to set the max number of groups in the field,
- `$headingAdditionalFields` - components in header,
- `$validation` - validation rules.

#### Adding cast

[](#adding-cast)

The field stores its values as a single JSON string. To use the Layouts field, you need to add a cast for your model.

```
use MoonShine\Layouts\Casts\LayoutsCast;

class Article extends Model
{
    protected function casts(): array
    {
        return [
            'content' => LayoutsCast::class,
        ];
    }
}
```

#### Customizing the button label

[](#customizing-the-button-label)

You can change the default "Add layout" button's text using the [ActionButton](https://moonshine-laravel.com/docs/3.x/components/action-button) component:

```
Layouts::make('Content')
    ->addButton(ActionButton::make('New layout')->icon('plus')->primary())
```

#### Adding search field

[](#adding-search-field)

You can add search input in layout list as follows:

```
Layouts::make('Content')
    ->addLayout('Info section', 'info', [
        // ...
    ])
    // ...
    ->addLayout('Slider section', 'slider', [
        // ...
    ])
    ->searchable()
```

#### Validation

[](#validation)

```
Layouts::make('Content')
    ->addLayout(
        'Info section',
        'info',
        [
            Email::make('Email')
        ],
        validation: ['email' => ['required', 'email']],
        attributes: ['email' => 'E-mail']
    )
```

```
Layouts::make('Content')
    ->addLayout('Info section', 'info', [
        Email::make('Email')
    ]),
    ->addLayout('Additionally section', 'additionally', [
        Text::make('Title')
    ])
    ->validation([
        'info' => ['email' => 'required'],
        'additionally' => ['title' => 'required']]
    )
```

```
Layouts::make('Content')
    ->addLayout('Info section', 'info', [
        Email::make('Email')
    ], validation: ['email' => ['email']], attributes: ['email' => 'E-mail']),
    ->addLayout('Additionally section', 'additionally', [
        Text::make('Title')
    ])
    ->validation(
        [
            'info' => ['email' => ['required']],
            'additionally' => ['title' => 'required']
        ],
        attributes: ['additionally' => ['title' => 'Заголовок']]
    )
```

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance76

Regular maintenance activity

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 77.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Total

24

Last Release

116d ago

Major Versions

0.7.0 → 1.0.02024-08-19

1.0.2 → 2.0.02024-10-19

1.x-dev → 2.0.12024-11-03

2.0.4 → 3.0.02025-11-04

2.0.5 → 3.0.12025-11-11

PHP version history (2 changes)0.0.1PHP ^8.0|^8.1|^8.2

2.0.0PHP ^8.1|^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1861327?v=4)[Danil Shutsky](/maintainers/lee-to)[@lee-to](https://github.com/lee-to)

---

Top Contributors

[![lee-to](https://avatars.githubusercontent.com/u/1861327?v=4)](https://github.com/lee-to "lee-to (53 commits)")[![Siesta](https://avatars.githubusercontent.com/u/7994849?v=4)](https://github.com/Siesta "Siesta (5 commits)")[![DissNik](https://avatars.githubusercontent.com/u/12373059?v=4)](https://github.com/DissNik "DissNik (4 commits)")[![povly](https://avatars.githubusercontent.com/u/48402954?v=4)](https://github.com/povly "povly (3 commits)")[![Reker7](https://avatars.githubusercontent.com/u/67463070?v=4)](https://github.com/Reker7 "Reker7 (2 commits)")[![shevl-dev](https://avatars.githubusercontent.com/u/118539450?v=4)](https://github.com/shevl-dev "shevl-dev (1 commits)")

---

Tags

fields-groupflexibleflexible-contentjsonmoonshinejsonFlexiblemoonshinefields-group

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/moonshine-layouts-field/health.svg)

```
[![Health](https://phpackages.com/badges/moonshine-layouts-field/health.svg)](https://phpackages.com/packages/moonshine-layouts-field)
```

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k334.7M790](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k504.8M167](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k141.9M929](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k92.4M680](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30525.1M57](/packages/colinodell-json5)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15882.2M31](/packages/clue-ndjson-react)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
