64robots / nova-fields Goto Github PK
View Code? Open in Web Editor NEWA collection of customizable Nova Fields.
Home Page: https://nova-fields.netlify.com
License: MIT License
A collection of customizable Nova Fields.
Home Page: https://nova-fields.netlify.com
License: MIT License
There is a bug with this editor when trying to add a question mark to the text area - and what's missing is the @keydown.stop reference to stop that from happening.
<template>
<trix-editor
ref="theEditor"
@keydown.stop
@trix-change="handleChange"
@trix-initialize="initialize"
@trix-attachment-add="handleAddFile"
@trix-attachment-remove="handleRemoveFile"
@trix-file-accept="handleFileAccept"
:value="value"
:placeholder="placeholder"
class="trix-content"
/>
</template>
I use json field for role permissions but, I can't update... Maybe its my wrong?
In Nova/Role
JSON::make('Permissions', [
Boolean::make('view_admin'),
]),
In Role
protected $casts = [
'permissions' => 'array',
];
I change casts permissions to object but again dont work...
resolveUsing is not working when applying on row's children
Row::make('Items', [
Text::make("Name")->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()
->resolveUsing(function ($value) {
$locale = app()->getLocale();
$item = json_decode($value, true);
return $item[$locale];
})->readOnly(),
Text::make("Quantity")->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()->readOnly(),
Text::make("Price")->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()->readOnly(),
])->hideWhenUpdating()->hideWhenCreating(),
Hello, how can i use this package?
i am trying to implement " Nova BelongsTo Or Create" but cant find a documentation for how to..
i have allready installed nova fields package
In the latest (?) release from 01.October you are able to "always show" textarea content (see laravel/nova-issues#649). Thats not working on your textarea
using repeatable rows to save to a JSON field in a db. Getting this error:
Undefined property: R64\NovaRow\Row::$resourceClass
{"userId":1,"email":"******@gmail.com","exception":"[object]
(ErrorException(code: 0): Undefined property: R64\\NovaRow\\Row::$resourceClass
at /home/vagrant/code/project/nova/src/Http/Controllers/AssociatableController.php:23)
aded package with: use R64\NovaRow\Row;
, and this is the usage:
Row::make('Questions', [
BelongsTo::make('Questions', 'questions', Question::class)
->sortable()
->hideFromIndex(),
])
Any idea what I'm missing here? The BelongsTo field works fine without the wrapper, but won't work with it.
We need documentation for common methods and detailed sections for each field
Hey, just wanted to let you know, that the asHtml
ist not working as in Nova core. This will not work:
Text::make('Example', function () {
return view('example')->render();
})->asHtml(),
The displayed contents should not be escaped.
Doing something like
JSON::make('Others', [ Date::make("Date", "dailyMenuDate")->resolveUsing( function ($value) { return Carbon::make($value)->format('Y-m-d'); }) ], "meta") ->rules('required', new DailyMenuRule),
Works in a weird way, Create and Updates are prevented but not error message is shown
Hello,
When I save or update a resource, I receive illegal string offset
while I set
$casts = [ 'contact' => 'object'];
Please advice,
Please Help me How to make BelongsTo here
Hello,
I have created json object as follow:
JSON::make('Meta', [
Boolean::make('Winner')
->yesLabel('Yea!')
->noLabel('Nope'),
Date::make('Win Date', 'win_date')
->format('DD MMM YYYY'),
Number::make('Points')
->min(0)
->max(100)
]),
When I save the form, Date field must cast to 'date' in Eloquent model
I tried to put:
protected $casts = [
'meta' => 'object',
'win_date' => 'date',
];
But it didn't work, please advice,
Hey, thanks again for another amazing Nova package!
It would be really great to also be able to manipulate the panel classes of a field:
i am using
Row::make('lineitems', [
Number::make('Quantity')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()->rules('required'),
BelongsTo::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/5 px-8 py-6')->hideLabelInForms()->addRowText('Add Product'),
giving me error Undefine Index :fields
Working with your package for building up some page content - awesome work so far. Wondering if there is any way to set a maximum number of rows/disable the add row button on the Row field?
Sometimes only there is two fields it would be nice if we can see from index
Unfortunately, I could not find a single normal tool that would allow the download of many related files and images in the resource editing card.
The solutions offered by Nova itself are not very convenient to use.
Hi,
Seems like the JSON fields are not validated. Would be really great to support this.
Is this something you are planning to implement in the future?
Many Thanks,
Tom
Can i use this package to make a custom form layout?
Like in nova-row?
Would it be possible to do something simliar to https://github.com/fourstacks/nova-repeatable-fields with the reordering ability? I could try and get a PR together for it since I do actually need the functionality but figured I would throw this in here for someone with a bit more time on their hands.
I'll help to create Wiki documentation.
I am trying authorization of JSON sub fields with something like this:
JSON::make('HelloWorld, [
Text::make('Example')
->canSeeWhen('seeExample', $this),
]),
But it does not seem to have any effect.
Can you think of a simple solution for this?
When you use hideLabelInForms() and change fieldClasses the fields gets misaligned with the headers.
I think it would be best to remove the field labels, and when you change field class it will change the header size keeping the alignment.
Hey, it seems that the sub fields of a row field are not validated. Are you planning to support this in the future?
We really need this, so we are thinking about implementing it ourselves. Maybe we can contribute via PR if you like and did not already start an implementation. Are there any pitfalls you are already aware of?
Thanks for the great package!
Similar to the BelongsTo field, it would be useful to create a new resource directly from the relationship panel.
Line 16 in f135097
As you guys probably know, normally with a nova text field in combination with a json attribute I can do the following:
Works:
// In model:
protected $casts = ['content' => 'array'];
// In resource:
Text::make('Example title', 'content->exampleTitle')
But when I am trying to do this in combination with the Row
field it doesn't resolve the saved value, the rows I created are not being displayed, however the data seems to be as expected in the database.
Broken:
// In model:
protected $casts = ['content' => 'array'];
// In resource:
Row::make('USPs', [
Text::make('Line'),
], 'content->usps')
Since nova-rows has been merged in this package, can we use:
Row::make('Lines', []) to make grid like forms?
Thanks.
Hello,
when I use like this:
JSON::make(false, [
Text::make('Title'),
Textarea::make('Description'),
//Tags::make('Keywords')->type('brands'),
])
any way to make that there is no padding on the left?
Hey,
fieldClasses
and labelClasses
at field level are ignored in Version 0.3.6
at the Update View.
Setup
at the Ressource:
JSON::make('Fieldname', $this->myFields(), 'fieldname')
Fielddefinition
public function myFields(): array
{
return collect([
R64Text::make(...),
R64Boolean::make(...)
])
->each->labelClasses('w-3/5 py-4 pr-4')
->each->fieldClasses('w-2/5 py-4')
->all();
}
Bug
developerbar display the old (default) classes.
<div class="flex border-b border-40" resource-id="2">
<div class="w-1/5 px-8 py-6">
<label class="inline-block text-80 pt-2 leading-tight" for="Labeltext">
Labeltext
</label>
<p class="text-sm leading-normal text-80 italic"></p>
</div>
<div class="w-1/2 px-8 py-6">
<input id="Labeltext" dusk="email_suffix" placeholder="Labeltext" type="text" class="w-full form-control form-input form-input-bordered">
<!---->
</div>
</div>
Debug
Dump of Fielddefinitions:
...
+fieldClasses: "w-2/5 py-4"
+panelFieldClasses: "w-3/4 py-4"
+labelClasses: "w-3/5 py-4 pr-4"
+panelLabelClasses: "w-1/4 py-4"
...
Request from Nova (Frontend) to Laravel at Route /:resource/2/update-fields
:
fieldClasses: "w-1/2 px-8 py-6"
fields: [
0: {
...
component: "nova-fields-text"
fieldClasses: "w-2/5 py-4"
labelClasses: "w-3/5 py-4 pr-4"
...
Number::make('Quantity')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
fieldClasses for Number does not exist?
Having hard time in applying field and label classes? Please some documentation will be helpful.
This and your other Nova packages do not contain a license.
Do you intend adding one in the future?
If you try to use common nova functions on fields inside a json-field, it is not working. For example:
\R64\NovaFields\JSON::make('Address', [
// Is showing on update screen
Text::make("City", 'city')->hideWhenUpdating(),
// Is showing on detail screen
Text::make('Postal Code', "zip")->hideFromDetail()
], 'json_data'),
When I use R64\NovaFields\JSON with R64\NovaFields\Text and ->help('Some text'), the help text is placed in the wrong column.
Json::make('Settings', [
Text::make('Bookons Unit', 'unit')
->help('The default unit (size) for Bookons, related to this project. Example: Meter, m2, kvm, Feet, Area… Can be overridden on individual items.')
,
Hi, with latest version a give an error with Row and BelongsTo when clicked on add row button in the create view and edit view
composer.json
"64robots/nova-fields": "^0.6.1",
My own nova resource
use R64\NovaFields\BelongsTo as CustomBelongsTo;
use R64\NovaFields\Number as CustomNumber;
use R64\NovaFields\Row;
use R64\NovaFields\Text as CustomText;
...
Row::make('Lines', [
CustomNumber::make('Cantidad', 'quantity')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()
->min(1)
->rules(
'required',
'integer',
'min:1'
)
->sortable(),
CustomText::make('Precio', 'price')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms()
->rules(
'required',
'string',
'regex:/^\d+((,|\.)\d{1,2})?$/'
)
->sortable(),
/**
* Relationships
*/
CustomBelongsTo::make('Producto', 'product', Product::class)
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
])
->fieldClasses('w-full px-8 py-6')
->labelClasses('w-1/2 px-8 py-6'),
When I am deleting during an update. After delete the row is removing from view but minimum row always 1. Is there any option to set minimum row to 0
Is it possible to store a row as json?
It would be nice to have grid laout or stacked fields like in nova row.
Thanks.
Let's say we have a textarea and want to add a css class, to shrink it:
\R64\NovaFields\Textarea::make("Öffnungszeiten", "opening_hours")
->inputClasses('height-75'),
where height-75
is a custom css class. But this will destroy the default layout, because it overwrites the default classe so you have to use everywhere:
\R64\NovaFields\Textarea::make("Öffnungszeiten", "opening_hours")
->inputClasses("w-full form-control form-input form-input-bordered py-3 min-h-textarea height-75"),
which is not really userfriendly, since you always have to look for the current css classes, have to maintain changes to these classes, etc.
Maybe add a second boolean option the the *Classes methods (inputClasses, labelClasses, etc.) do decide, if we want to append or override the default classes. Something like this:
// Same behavior like now: Overwrite it
\R64\NovaFields\Textarea::make("Öffnungszeiten", "opening_hours")
->inputClasses('height-75'),
// Will append, instead of overwrite
\R64\NovaFields\Textarea::make("Öffnungszeiten", "opening_hours")
->inputClasses('height-75', false),
The json field is saving values as null in the database
The image url is always empty when i save my resource.
images: "[{"image":"","caption":"test"}]"
Here's the code in my resource class:
Row::make('Images', [
Image::make('image')
->disk('public')
->path('images')
->hideLabelInforms()
->fieldClasses('w-full px-8 py-6'),
Text::make('caption')
->hideLabelInforms()
->fieldClasses('w-full px-8 py-6')
])
->hideLabelInForms()
->fieldClasses('w-full px-8 py-6'),
Currently the readOnly is applied on all views, but it would be nice to enable readOnlyOnUpdate as well.
Nova doesn’t have float type field.
Maybe you can add support within this library?
I mean:
<input type="number" step="0.01">
Maybe I'm missing something but the resolveUsing code doesn't even get hit at all? On version 0.6.1.
Adding a dd
into the resolveUsing callback is never called. In fact adding a dd to either the row or the inner row fields seem to do nothing.
Snippet as an example:
Row::make('Features and Benefits', [
Text::make('test', null, function($feature) {
dd('test');
}),
Textarea::make('Feature/Benefit', 'feature', function ($feature) {
dd('test');
return $feature;
})->hideLabelInForms()
], 'features')
Granted I'm trying to do something like a list where the result is just an array of strings, but the logic should still be getting hit.
ADDITIONAL UPDATE: It also broke using a resolveUsing on the Row field itself. reverting back to 0.6.0 makes the row field level resolve work again
ADDITIONAL ADDITIONAL UPDATE:
Snippet for example of Row level resolve/fil working in 0.6.0 but broken completely in 0.6.1
Row::make('Features and Benefits', [
Textarea::make('Feature/Benefit', 'feature')->hideLabelInForms()
], 'features', function ($features) {
return collect($features)->map(function ($feature) {
return ['feature' => $feature];
});
})->fillUsing(function (NovaRequest $request, $model, $attribute, $requestAttribute) {
if ($request->exists($requestAttribute)) {
// Ensure we don't store that random row_id that gets generated
$model->{$attribute} = collect($request[$requestAttribute])->pluck('feature')->flatten()->filter();
}
})->fieldClasses('w-full px-8 py-6')->hideHeading()->addRowText('Add Feature'),
I know this kind of logic isn't quite in line with how it's supposed to work, but still a very breaking change based on how fields are supposed to work in Nova.
Also noting that using the more general syntax of calling resolveUsing
on the Row field also doesn't work as expected.
I figured this level of breakage deserves it's own issue rather than just piggy backing on an old closed issue #49)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.