All Projects → ajmariduena → nova-dynamic-field

ajmariduena / nova-dynamic-field

Licence: other
Dynamic field for Laravel Nova

Programming Languages

PHP
23972 projects - #3 most used programming language
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to nova-dynamic-field

nova-settings
A tool for editing settings on your project using akaunting/setting package on Laravel Nova
Stars: ✭ 18 (+0%)
Mutual labels:  settings, laravel-nova
Pointy
A jQuery plugin that dynamically points one element at another ~
Stars: ✭ 25 (+38.89%)
Mutual labels:  dynamic
configster
Rust library for parsing configuration files
Stars: ✭ 19 (+5.56%)
Mutual labels:  settings
nova-conditional-fields
WIP: Conditionally display fields based on another field's value
Stars: ✭ 38 (+111.11%)
Mutual labels:  laravel-nova
readme-components
Cards for your readme
Stars: ✭ 44 (+144.44%)
Mutual labels:  dynamic
tform
A easy, extensible and dynamic flutter form framework. Support for custom selectors, validators and widgets. Support form verification, insert, delete and so on.
Stars: ✭ 30 (+66.67%)
Mutual labels:  dynamic
NSL
Implementation for <Neural Similarity Learning> in NeurIPS'19.
Stars: ✭ 33 (+83.33%)
Mutual labels:  dynamic
nova-opcache
OPcache Tool for Laravel Nova
Stars: ✭ 21 (+16.67%)
Mutual labels:  laravel-nova
typijs
The Angular CMS Framework for building fully-featured SPA sites powered by NodeJS and MongoDB with TypeScript
Stars: ✭ 141 (+683.33%)
Mutual labels:  dynamic
dlib
Dynamic loading library for C/C++
Stars: ✭ 19 (+5.56%)
Mutual labels:  dynamic
DynamicQueryable
λ Construct Linq queries using strings.
Stars: ✭ 46 (+155.56%)
Mutual labels:  dynamic
1pt
A URL shortener with protection against malicious redirects
Stars: ✭ 20 (+11.11%)
Mutual labels:  dynamic
mmwm
Modern Minimalistic Window Manager
Stars: ✭ 45 (+150%)
Mutual labels:  dynamic
nova-list-card
Add a variety of resource lists to Nova dashboards
Stars: ✭ 39 (+116.67%)
Mutual labels:  laravel-nova
nova-assertions
Laravel Nova assertions for your tests
Stars: ✭ 76 (+322.22%)
Mutual labels:  laravel-nova
laravel-notification-settings
🔒 A Laravel package that allows you to check the notification settings before send them.
Stars: ✭ 28 (+55.56%)
Mutual labels:  settings
Telescope
Telescope is an engine for efficiently creating meaningful visualizations
Stars: ✭ 26 (+44.44%)
Mutual labels:  dynamic
MaterialPreferences
🍉 An Android library that lets you implement MaterialPreferences on Setting UI.
Stars: ✭ 21 (+16.67%)
Mutual labels:  settings
nova-table-field
Table field for Laravel Nova
Stars: ✭ 29 (+61.11%)
Mutual labels:  laravel-nova
SettingsUI
Windows 11 settings page in WinUI 3 applications ported from Powertoys
Stars: ✭ 95 (+427.78%)
Mutual labels:  settings

Dynamic Field for Laravel Nova

Useful for something like settings on a content management system.

Installation

You can install this package into a Laravel app that uses Nova via composer:

composer require ajmariduena/dynamic-field

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

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

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

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].