PHPackages                             ajmariduena/dynamic-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ajmariduena/dynamic-field

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ajmariduena/dynamic-field
=========================

A Laravel Nova field.

0.0.1(7y ago)1822.9k↓50%3[2 issues](https://github.com/ajmariduena/nova-dynamic-field/issues)MITPHPPHP &gt;=7.1.0

Since Dec 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ajmariduena/nova-dynamic-field)[ Packagist](https://packagist.org/packages/ajmariduena/dynamic-field)[ RSS](/packages/ajmariduena-dynamic-field/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Dynamic Field for Laravel Nova
==============================

[](#dynamic-field-for-laravel-nova)

Useful for something like settings on a content management system.

Installation
------------

[](#installation)

You can install this package into a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require ajmariduena/dynamic-field
```

Usage
-----

[](#usage)

Imagine we have a table like this:

```
Schema::create('settings', function (Blueprint $table) {
    $table->increments('id');
    $table->string('key');
    $table->string('display_name')->nullable();
    $table->text('value')->nullable();
    $table->string('type');
});
```

On Setting nova resource:

```
use Ajmariduena\DynamicField\DynamicField;

public function fields(Request $request)
{
    return [
        Text::make('Name'),
        Select::make('Type')->options([
            'text' => 'Text',
            'date' => 'Date',
            'boolean' => 'Boolean',
            'textarea' => 'Textarea',
            'trix' => 'Trix',
            'code' => 'Code',
        ]),
        DynamicField::make('Value')->baseOn('type')
    ];
}
```

This will render a field base on type value on settings table.

### Currently supported types

[](#currently-supported-types)

- Text ( text )
- Date ( date )
- Boolean ( boolean )
- Textarea ( textarea )
- Trix ( trix )
- Code ( code )
    - `->json()` is supported.
    - `->language('php')` is supported.

### Caveats

[](#caveats)

For boolean type you need to cast to int value in order to make it work.

Example using Accessor:

```
class Setting extends Model
{
    public function getValueAttribute($value)
    {
        switch ($this->type) {
            case 'boolean':
                return (int)$value;
            default:
                return $value;
        }
    }
}
```

License
-------

[](#license)

Copyright 2018 Alexander Maridueña

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2718d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31521624?v=4)[Alexander Josue Maridueña Canseco](/maintainers/ajmariduena)[@ajmariduena](https://github.com/ajmariduena)

---

Top Contributors

[![ajmariduena](https://avatars.githubusercontent.com/u/31521624?v=4)](https://github.com/ajmariduena "ajmariduena (5 commits)")

---

Tags

dynamiclaravellaravel-novasettingslaravelnova

### Embed Badge

![Health badge](/badges/ajmariduena-dynamic-field/health.svg)

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

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3403.5M7](/packages/optimistdigital-nova-multiselect-field)[digital-creative/conditional-container

Provides an easy way to conditionally show and hide fields in your Nova resources.

116593.8k4](/packages/digital-creative-conditional-container)[genealabs/laravel-overridable-model

Provide a uniform method of allowing models to be overridden in Laravel.

92398.0k2](/packages/genealabs-laravel-overridable-model)[inspheric/nova-defaultable

Default values for Nova fields when creating resources and running resource actions.

51174.8k1](/packages/inspheric-nova-defaultable)[murdercode/nova4-tinymce-editor

Boost your Laravel Nova with the TinyMCE editor.

17165.2k](/packages/murdercode-nova4-tinymce-editor)[yieldstudio/nova-google-autocomplete

A Laravel Nova Google autocomplete field.

12218.4k](/packages/yieldstudio-nova-google-autocomplete)

PHPackages © 2026

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