Giter VIP home page Giter VIP logo

nova-row's Introduction

Important

This field has been merged to Custom Nova Fields package. Keep track of it for updates!

Row Field for Laravel Nova

This field allows you to create horizontal rows passing a collection of Custom Nova Fields.

Demo

Demo

Install

Run this command in your nova project: composer require 64robots/nova-fields

Add it to your Nova Resource:

Create a new Row field passing an array of Nova Fields as a second param. Attribute name can be passed as third param.

As we are using R64 Nova Fields. We can customize the classes and hide the field labels.

use R64\NovaFields\Row;

Row::make('Lines', [
      Number::make('Quantity')
        ->fieldClasses('w-full px-8 py-6')
        ->hideLabelInForms(),
      Text::make('Product')
        ->fieldClasses('w-full px-8 py-6')
        ->hideLabelInForms(),
      Number::make('Price')
        ->fieldClasses('w-full px-8 py-6')
        ->hideLabelInForms(),
    ])->fieldClasses('w-full px-8 py-6')
      ->labelClasses('w-1/2 px-8 py-6'),

This converts to an array of objects.

[
  { quantity: 1, product: 'This One', price: 20 },
  { quantity: 2, product: 'That One', price: 21 }
];

Localization

Set your translations in the corresponding xx.json file located in /resources/lang/vendor/nova

...

  "Add Row": "Añadir Fila",
  "Delete Row": "Eliminar Fila",
  "Are you sure you want to delete this row?": "¿Estás seguro de querer eliminar esta fila?"

nova-row's People

Contributors

beliolfa avatar robmpreston avatar casperlaitw avatar

Stargazers

 avatar Mikail LEKESIZ avatar  avatar qalainau avatar caizhigang avatar Osman Zeki avatar Edgar Nadal avatar Bader  avatar Jordan Hall avatar Anatoli Nicolae avatar Connor S. Parks avatar  avatar Arthur Monney avatar Ken Verhaegen avatar Jeroen Nijhuis avatar  avatar Gonzalo Nandez avatar

Watchers

qalainau avatar James Cloos avatar  avatar  avatar

nova-row's Issues

Setting default classes on form elements

This package is great, and works really well with Nova Fields.

When you implement another package say FilemanagerField it would be nice if you could set a default width / toggle off labels so that the fields that you can't call methods on can still be aligned nicely.

To prevent something like the below:

screen shot 2018-09-12 at 16 21 18

Something like:

->defaultFieldClasses('w-full px-8 py-6')->defaultHideLabelInForms()

[Feature Request] Row ordering

Ability to change the order of the resulting json by dragging and dropping the rows or with up/down arrows on each row, Im including some UI inspiration

interactions

[Feature Request] Callback save/update handling

Ability to pass a callback to Row that receives the resource, a collection of rows and allows freedom to process via eloquent in scenarios where json is not the desired outcome.

public function fields() 
{
    return [

        Row::make('Items', $this->itemFields())

            ->saving(function($order, $items) {

                $items->each(function($item) use($order) {
                    $order->items()->save($item);
                });

            });
    ];
}

public function itemFields()
{
    return [
        Text::make('Product'),
        Number::make('Quantity'),
        Number::make('Price')
    ];
}

How to save data on table?

it always show [object Object],[object Object] so how should I persist the data in database. I have made price column with json field type.

Here is field detail.


            Row::make('Price', [
                Text::make('Currency')
                  ->fieldClasses('w-full px-8 py-6')
                  ->hideLabelInForms(),

                Number::make('Amount')
                  ->fieldClasses('w-full px-8 py-6')
                  ->hideLabelInForms(),

              ])->fieldClasses('w-full px-8 py-6')
                ->labelClasses('w-1/2 px-8 py-6'),

Now when i submit post in database it is stored as [object Object] etc..

[Feature Request] Remove nova-fields dependency

Would absolutely love this package if it didn't require the overriding of Nova's fields with 3rd party implementation. I really feel the style choices you made should just be baked in, there isn't much need for using the class methods then.

Regarding validation

is it possible to have validation like at least one row is require or maximum 10 rows.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.