whitecube / nova-flexible-content Goto Github PK
View Code? Open in Web Editor NEWFlexible Content & Repeater Fields for Laravel Nova
License: MIT License
Flexible Content & Repeater Fields for Laravel Nova
License: MIT License
Adding "belongsTo" field into the "addLayout" triggers error "Call to a member function xy() on array"
In the documentation it is written than all Laravel Nova fields are supported.
We tried adding BelongsTo fields like this:
Flexible::make('flex_data')->addLayout('Simple content section', 'test', [BelongsTo::make('xy'),]),
Because i used indexing with integer and it didn't work I'm posting this just in case you think its a bug i had the following error :
strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
And had to change whitecube/nova-flexible-content/src/Http/ScopedRequest.php
Around line 130 from:
$analysis['raw'] = substr($attribute, strpos($attribute, $key) + strlen($key . '__'));
To:
$analysis['raw'] = substr($attribute, strpos($attribute, strval($key)) + strlen($key . '__'));
Might add I use PHP version 7.3.3 but on my other machine with PHP 7.2.* it worked without the fix.
Nova Version: 2.0.5
Plugin Version: 0.1.6
I have a block of code in my that adds a nested repeatable field. Which looks like the following:
->addLayout('Fifty/Fifty Block', 'fifty_split', [
Flexible::make('Items')
->addLayout('Image', 'image', [
Image::make('Image', 'image')
])
->addLayout('Video', 'video', [
Image::make('Cover', 'cover'),
Text::make('Video URL', 'video_url')
])
->addLayout('Text', 'text', [
Text::make('Heading'),
NovaTrumbowyg::make('Body')
])
])
When I add a new top-level field, it'll create the necessary block and allow for me to fill out the data as intended. I'll fill out several images and content then save, and it'll only save the images for the first "Fifty Fifty Block" and delete the images for the latter while keeping the subfields.
The Whitecube\NovaFlexibleContent\Value\Resolver
resolvers extractValueFromResource
method does at the moment only handle strings and arrays. But eloquent models also have the ability to represent an array with the collection accessor, which is just an encapsulated array but php's is_array
function will be false. The simple solution would be to check for collections and use their array value:
if($value instanceof Collection) return $value->toArray();
I have this error when saving the resource:
exception: "Exception" file: "G:\laravel\headless\vendor\whitecube\nova-flexible-content\src\Flexible.php" line: 268 message: "Unable to parse incoming Flexible content, data should be an array."
my fields:
`public function fields(Request $request)
{
return [
ID::make()->sortable(),
Flexible::make('Content')
->addLayout('Simple content section', 'wysiwyg', [
Text::make('Title'),
Markdown::make('Content')
])
->addLayout('Video section', 'video', [
Text::make('Title'),
Image::make('Video Thumbnail', 'thumbnail'),
Text::make('Video ID (YouTube)', 'video'),
Text::make('Video Caption', 'caption')
]),
];
}`
model:
`class Page extends Model
{
protected $fillable = [ 'content'];
protected $casts = [
'content' => 'array'
];
}`
nova version: 2.0.11
laravel version: 5.8.32
Hi there,
First of all thanks for this wonderful package!
I'm trying to use the fields provided by advanced-nova-media-library (https://github.com/ebess/advanced-nova-media-library/) in a nova-flexible-content. So far I'm having no success. The media library package works on top of spatie's media library.
It would be great if we could add photos by using your package.
Images::make('Photo', 'photo')
I'm using a custom resolver and have no clue what to return in the get method or how to save the data in the set method. I keep getting the error: "Call to a member function getMedia() on array" whenever I try to access my resource in the Nova backend.
I know this might not really be an issue with this package, but since the community around Nova and these packages is so small, I figured I should just ask here.
Thanks in advance.
An image cannot be downloaded.
Reproduce:
Issue
Can't resolve resource type and ID.
URL will be something like: https://example.com/nova-api/undefined/undefined/download/
I use "Ebess\AdvancedNovaMediaLibrary" for images gallery and got error: Call to a member function getMedia() on array
Code:
Flexible::make('Gallery')
->addLayout('Simple content section', 'wysiwyg', [
Images::make('Computer case', 'computer-image-case')
->conversionOnIndexView('thumb')
]
Flexible without Images::make work fine. Images::make without Flexible work fine.
Hi All, Thanks for this amazing package.
I have a question, I tried using ->store method for Image field to resize, but nothing happened. FYI: I able to use this method in default Image nova field.
Am I missing something here?
Thanks
->store(function (Request $request) {
$image = doin_resize_function();
return [
'image' => $image
];
})
The most awesome package for nova so far! Thanks for the great work!
However, when I use the package with Nova Field Dependency Container or Nova Radio Buttons for example to show/hide the flexible field depends on other field value. I got an error message saying "Unable to parse incoming Flexible content, data should be an array"
whenever the field is hidden, it works just fine when it's shown.
Even though these packages really hide the field and don't send it's content with the request, but still Flexable Content package tries to resolve the field.
As a quick fix, I wrapped syncAndFillGroups function in the vendor/whitecube/nova-flexible-content/src/Flexible.php
with an isset() condition to be like:
protected function syncAndFillGroups(NovaRequest $request, $requestAttribute)
{
if( isset($request[$requestAttribute])){
$raw = json_decode($request[$requestAttribute]);
if(!is_array($raw)) {
throw new \Exception("Unable to parse incoming Flexible content, data should be an array.");
}
$this->groups = collect($raw)->map(function($item, $key) use ($request) {
$layout = $item->layout;
$key = $item->key;
$attributes = (array) $item->attributes;
$group = $this->findGroup($key) ?? $this->newGroup($layout, $key);
if(!$group) return;
$group->fill(ScopedRequest::scopeFrom($request, $attributes, $key));
return $group;
});
}
}
Hi all, Thanks so much for this great package!
I updated to v0.1.8 yesterday and ran into some trouble with presets.
I have the following in TwoColumns.php
public function fields()
{
return [
Flexible::make('Left column')
->preset(\App\Nova\Flexible\Presets\TwoColumnsPreset::class),
Flexible::make('Right column')
->preset(\App\Nova\Flexible\Presets\TwoColumnsPreset::class),
];
}
Both of those columns use a preset. In this case TwoColumnsPreset.php
public function handle(Flexible $field)
{
$field->hideFromIndex()
->addLayout(\App\Nova\Flexible\Layouts\TextSection::class)
->addLayout(\App\Nova\Flexible\Layouts\BulletList::class)
->addLayout(\App\Nova\Flexible\Layouts\CheckList::class)
->addLayout(\App\Nova\Flexible\Layouts\VideoEmbed::class)
// e.t.c...
}
In v0.1.7 this worked without any issues, but since the v0.1.8 update Nova throws an error when adding flexible fields to the first column. The peculiar thing is that adding layouts to the second works as expected.
When trying to store data in the left column Nova throws an exeption with the message Unable to parse incoming Flexible content, data should be an array.
. Below I've posted part of the trace:
It doesn't matter what type of presets are added to a layout. If I remove all inputs other than a textfield for example this error still occurs.
Is this a bug or am I doing something wrong? Hope you can reproduce and help me out :)
Thanks!
Example:
Flexible::make('Guías', 'guides')
->addLayout('Guía', 'guide', [
Text::make('No. Guía', 'guide_number')
->rules('required')
])
Hi. I have similar problem.
Unable to parse incoming Flexible content, data should be an array.
I updated to 0.1.9 but problem not resolved for me.
My resource have this Flexible field
Flexible::make('Содержание новости', 'body_json')
->addLayout('Блок с текстом', 'wysiwyg', [
Text::make('Заголовок', 'title'),
NovaTrumbowyg::make('Содержание', 'body')
])
->addLayout('Youtube видео', 'video', [
Text::make('Заголовок', 'title'),
Image::make('Video Thumbnail', 'thumbnail'),
Text::make('ID видео (YouTube)', 'video'),
Text::make('Примечание к видео', 'desc')
])
->button('Добавить блок')
Originally posted by @Bessamu in #53 (comment)
v0.1.8 doesn't work when we wrap a Flexible field with R64 Nova Fields' JSON field (https://github.com/64robots/nova-fields/).
Example code:
JSON::make('Details', [
Flexible::make('Student Choice Selections', config('magento.gp_bundle_student_choices'))
->button('Add Student Choice Item')
->addLayout('Student Choice Selections', 'student_choice_selections', [
Text::make('Choice Description', config('magento.gp_bundle_student_products.selection_title'))
->fieldClasses('choice-description-field px-8 py-6')
->rules('required'),
...
], 'data')->fieldClasses('w-full')
->labelClasses('w-1/6 px-8 py-6 hidden')
->hideFromIndex(),
We get this error:
localhost.ERROR: Unable to parse incoming Flexible content, data should be an array. {"userId":2,"exception":"[object] (Exception(code: 0): Unable to parse incoming Flexible content, data should be an array. at /var/www/html/vendor/whitecube/nova-flexible-content/src/Flexible.php:268)
I know it's expecting an array, but we need our data in JSON format. Is there any workaround?
If nova-flexible-content is used as a simple repeatable field with the same layout everytime the layouts title is not really needed. If the title is omitted by setting it to null or empty the view should not display an empty bar at the top of the layout on form pages:
Additionally the top-row on the index page could be removed as there is no layout name to display:
I am trying to use this one but I get js error when trying to save. If I don't add any layout object is currectly saved.
$recapiti_field = Flexible::make("recapiti", "recapiti"); $recapiti_field = $recapiti_field->addLayout('Recapito', 'recapito_layout', [ Text::make('Recapito','recapito'), ]); $fields[] = $recapiti_field;
recapiti is model attribute name (db column) declared as mediumtext and casted as "json" in my model. I've tried to cast it to "array" and don't cast it at all, but outcome is the same.
Any ideas?
This is the complete js error:
vendor.js?id=da751a53228a35fab7c4:1 TypeError: Cannot read property 'status' of undefined at p.<anonymous> (app.js?id=e278aec4bd99815664dd:1) at y (app.js?id=e278aec4bd99815664dd:1) at Generator._invoke (app.js?id=e278aec4bd99815664dd:1) at Generator.e.<computed> [as next] (app.js?id=e278aec4bd99815664dd:1) at o (app.js?id=e278aec4bd99815664dd:1) at app.js?id=e278aec4bd99815664dd:1 at new Promise (<anonymous>) at new t (app.js?id=e278aec4bd99815664dd:1) at p.<anonymous> (app.js?id=e278aec4bd99815664dd:1) at p.<anonymous> (app.js?id=e278aec4bd99815664dd:1)
Hey @Nyratas really appreciate your hard work. it's adding a lot of value to the project I'm working on.
Found a small problem with the latest update which adds compatibility with ebess/advanced-nova-media-library
. Considor this (very basic) Layout:
<?php
namespace App\Nova\Flexible\Layouts;
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Whitecube\NovaFlexibleContent\Concerns\HasMediaLibrary;
use Whitecube\NovaFlexibleContent\Layouts\Layout;
class FeaturedImageLayout extends Layout implements HasMedia
{
use HasMediaLibrary;
protected $name = 'featured_image';
protected $title = 'Image';
public function fields()
{
return [
Images::make('Image', 'image')
];
}
}
If I add 2 of the "Image" fields and add images to each individually, the last added "Image" layout will take precedence and override the previous layout's images.
If I had to take a guess on why, it's because they are using the same collection name (i.e. "image").
Would appending the collection name with the field key (e.g. "images_8ad236757d5bad60") solve this problem?
Hi, I'm trying to get this package work on multilingual setup but in my views the content returns null
.
Packages used:
"mrmonat/nova-translatable": "^2.0",
"spatie/laravel-translatable": "^4.1",
"whitecube/nova-flexible-content": "dev-master"
Page model:
<?php
namespace App\Models;
use App\Nova\Flexible\Layouts\IntroBlockLayout;
use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;
use Whitecube\NovaFlexibleContent\Concerns\HasFlexible;
class Page extends Model
{
use HasSlug, HasTranslations, HasFlexible;
/**
* Sets table name.
*
* @var string
*/
protected $table = 'pages';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'title',
'slug',
'content',
];
/**
* The attributes that are translatable.
*
* @var array
*/
public $translatable = [
'title',
'slug',
'content',
];
/**
* Get the options for generating the slug.
*/
public function getSlugOptions()
{
return SlugOptions::create()
->generateSlugsFrom('title')
->saveSlugsTo('slug');
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'slug';
}
public function getFlexibleContentAttribute()
{
return $this->flexible('content', [
'introblock' => IntroBlockLayout::class,
]);
}
}
Custom layout (IntroBlockLayout):
<?php
namespace App\Nova\Flexible\Layouts;
use MrMonat\Translatable\Translatable;
use Whitecube\NovaFlexibleContent\Layouts\Layout;
class IntroBlockLayout extends Layout
{
/**
* The layout's unique identifier
*
* @var string
*/
protected $name = 'introblock';
/**
* The displayed title
*
* @var string
*/
protected $title = 'Intro Block';
/**
* Get the fields displayed by the layout.
*
* @return array
*/
public function fields()
{
return [
Translatable::make('title'),
Translatable::make('text'),
];
}
}
View show.blade.php:
{{ $page->flexible('introblock') }}
{{ $page->getFlexibleContentAttribute() }}
Content field in DB:
{"en": [{"key": "dadcc3bbc6104575", "layout": "introblock", "attributes": {"text": {"da": "Da Text", "de": "De Text", "en": "En Text"}, "title": {"da": "Da title", "de": "De title", "en": "En title"}}}]}
both attempts to render the content in the view return null. Any idea what I'm doing wrong here?
Omitting button type in the views causes the browser to activate the first button in the markup rather than the submit button of the form when pressing enter. You have to add type="button"
on all buttons in the view.
Previously we were getting this error (#55), so I decided to update from 0.1.7 to 0.1.9. That error is gone, but now I'm getting a completely different error when trying to create/update. The create/update button won't let me submit. Here's the JS error:
TypeError: Cannot read property 'status' of undefined
at p.<anonymous> (app.js?id=b8265367338097693595:formatted:13231)
at y (app.js?id=b8265367338097693595:formatted:16860)
at Generator._invoke (app.js?id=b8265367338097693595:formatted:16838)
at Generator.e.<computed> [as next] (app.js?id=b8265367338097693595:formatted:16875)
at o (app.js?id=b8265367338097693595:formatted:22898)
at app.js?id=b8265367338097693595:formatted:22910
at new Promise (<anonymous>)
at new t (app.js?id=b8265367338097693595:formatted:25246)
at p.<anonymous> (app.js?id=b8265367338097693595:formatted:22895)
at p.<anonymous> (app.js?id=b8265367338097693595:formatted:13239)
It @ vendor.js?id=da751a53228a35fab7c4:formatted:39444
The culprit might be R64's Nova Fields again (if that's the case, I'll open a ticket with them), but we need to wrap Flexible content and a few other fields in this R64 JSON field for our data needs:
JSON::make('Details', [
Text::make('Test', 'test'),
Text::make('Test 2', 'test2'),
Flexible::make('Student Choice Selections', config('magento.gp_bundle_student_choices'))
->button('Add Student Choice Item')
->addLayout('Student Choice Selections', 'student_choice_selections', [
Text::make('Choice Description', config('magento.gp_bundle_student_products.selection_title'))
->fieldClasses('choice-description-field px-8 py-6')
->rules('required'),
Text::make('Test 3', 'test3'),
Text::make('Test 4', 'test4'),
], 'data')->fieldClasses('w-full')
->labelClasses('w-1/6 px-8 py-6 hidden')
->hideFromIndex(),
Wrapping it with another Flexible field instead of this JSON field isn't going to work for us.
When I try to use flexible-content with 64robots/nova-fields's json field, the image value gets removed.
I have other non-repeatable fields that need to have its value stored together in the json column in my database. Since flexible-content only saves its own data in the json column, in order to overcome this behaviour, I've included 64robots/nova-fields' json field, so that I can save other data together with flexible-content's data.
<?php
use Laravel\Nova\Fields\Heading;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Image;
use R64\NovaFields\JSON;
public function fields(Request $request)
{
return [
Heading::make('Hero'),
// Stores it as 'title' under 'content' json column.
Json::make('', [Text::make('title')], 'content'),
Heading::make('Gallery Images'),
// Stores it as 'gallery_images' under 'content' json column.
Json::make('', [
Flexible::make('Gallery Images')
->addLayout('Gallery section', 'gallery', [
Text::make('Title'),
Image::make('Video Thumbnail', 'thumbnail'),
]),
], 'content'),
];
}
I'm currently using "whitecube/nova-flexible-content": "^0.1.4"
Not a bug per se, just a suggestion. I'm using this package in a project and the client just complained that the delete button is too close to the move up/down arrows, and that it prompts no dialog when clicked, leading to deleting things by accident (which happened). Anyway, just a suggestion for a small UX improvement. If you accept PRs I can probably make one with a javascript confirmation dialog. As of now (and probably this month), I don't have enough time for a fancier modal.
My current problem is when editing, it shows everything okay, and the values are user friendly. But when i go into detail view, it shows the IDs but i would like to display values.
My inital solution was using 2 different presets and resolvers, and using "hideFromDetail" and "hideWhenCreating hideWhenUpdating" but it does not work. Does anyone have an idea what to do ?
So i have my preset set like this:
public function handle(Flexible $field) {
// Add button to FE
$field->hideFromIndex();
$field->button('Add Leg');
// Format the airports and flight purpose collection into an array [id => name]
$airports = $this->airports->reduce(function ($values, $airport) {
$values[$airport->id] = $airport->mark;
return $values;
}, []);
$flight_purposes = $this->flight_purposes->reduce(function ($values, $flight_purpose) {
$values[$flight_purpose->id] = $flight_purpose->name;
return $values;
}, []);
// Creating a layout
$field->addLayout('Flight info', 'flight_info_layout', [
DateTime::make('Date from'),
DateTime::make('Date to'),
Select::make('Take off', 'take_off')
->options($airports)
->displayUsingLabels(),
Select::make('Landing', 'landing')
->options($airports)
->displayUsingLabels(),
Select::make('Flight Purpose', 'flight_purpose')
->options($flight_purposes)
->displayUsingLabels(),
Number::make('Total Time', 'totalizer')->step(0.01),
// Number::make('Length km', 'length_km'),
Number::make('Lap number', 'lap_number'),
DateTime::make('Block off', 'block_off'),
DateTime::make('Block on', 'block_on'),
]);
// Then attach a custom resolver that will take care of the real eloquent relationship
$field->resolver(\App\Nova\Flexible\Resolvers\ChronometryPowerFlightInfoResolver::class);
}
And my resolver getter:
public function get($resource, $attribute, $layouts) {
// First we'll fetch the flight_info linked to the resource (from Model)
$flight_info = collect(json_decode($resource->flightInfo));
if (empty($flight_info)) {
return null;
}
// Now we'll map them into the Chronometries layout
return $flight_info->map(function ($flight, $key) use ($layouts) {
$layout = $layouts->find('flight_info_layout');
// Using duplicateAndHydrate, we'll create a copy of the original
// Layout and fill it with the current author's data
if (isset($flight->block_off) && isset($flight->block_on)) {
$block_on = Carbon::parse($flight->block_on);
$block_off = Carbon::parse($flight->block_off);
} else {
$block_on = Carbon::parse('0000-01-01 00:00:00', 'UTC');
$block_off = Carbon::parse('0000-01-01 00:00:00', 'UTC');
}
return $layout->duplicateAndHydrate($key, [
'date_from' => Carbon::parse($flight->date_from),
'date_to' => Carbon::parse($flight->date_to),
'take_off' => $flight->take_off->id,
//'take_off' =>"THIS IS A TEST AND IT SHOWS THIS TEXT ON VIEW"
'landing' => $flight->landing->id,
'flight_purpose' => $flight->flight_purpose->id,
'totalizer' => $flight->totalizer,
// 'length_km' => $flight->length_km,
'lap_number' => $flight->lap_number,
'block_off' => $block_off,
'block_on' => $block_on,
]);
});
}
The main idea / problem behind this issue is the impossibility to create dynamic rows inside of a Flexible field.
With the Row field (package: nova-fields) you can create dynamic amount of rows by defining columns. Like this:
use R64\NovaFields\Row;
use R64\NovaFields\Select as RowSelect;
use R64\NovaFields\Text as RowText;
.
.
.
Row::make('Lines', [
RowSelect::make('Column 1 title')->options([
0 => 'Example option 1',
1 => 'Example option 2',
2 => 'Example option 3'
])
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
RowText::make('Column 2 title')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
])
However, if you try to insert the code above into a Flexible you get an error. Example:
Flexible::make(__('reports.reviews'))
->button('Add a section')
->addLayout('This is the title of a section', 'review_lines', [
Row::make('Lines', [
RowSelect::make('Column 1 title')->options([
0 => 'Example option 1',
1 => 'Example option 2',
2 => 'Example option 3'
])
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
RowText::make('Column 2 title')
->fieldClasses('w-full px-8 py-6')
->hideLabelInForms(),
]),
])
"Trying to get property 'lines' of non-object”.
It would be really handy to be able to add rows dynamically inside a Flexible.
I am not sure if this is a bug or something that I am missing on my end.
I've followed up the documentation to create a flexible content and when I try to submit the modal It returns this error on the console:
Here is the flexible content on a custom action:
Here is my action modal:
Is there anything else that I need to do on my end?
Hey All,
Tried to save an element having 3 nested children, which has a key total of 3. In the ScopedRequest.php you're checking against the count of the keys and then doing some work off that to get the nested files. With having exactly 3 child items, it seems to throw an issue here.
Not sure if we can detect anything else? Having 2/4 seems to work. I'm guessing this is due to the default structure you have of
[
'layout' => '',
'key' => '',
'attributes' => ''
]
The error being returned in the log is
[message]
Undefined index: key {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined index: key at /Users/jack/Sites/travelteer/vendor/whitecube/nova-flexible-content/src/Http/ScopedRequest.php:95)
Using v0.1.9.
If I'm trying to access a field's value that is inside a JSON (ie data->title
, where data
is JSON), the resolver fails to retrieve the value. More specifically, the extractValueFromResource
function.
I propose that extractValueFromResource
should work similary to Nova's Field
resolveAttribute
.
Trying to upload an image to a nested flexible field content and the image will not process.
I'm trying to use the Spatie TagsField for Nova, but no luck.
Im getting "trying to getting property 'tags' of non-object".
Could that be made working?
Thanks for the awesome package!
Moving up/down a layout does not move its File fields. Deleting works fine.
For example:
The following source code appears to work on building the layout, but when the subfield (Flexible field) is added, then all subsequent subfields share the data from the first subfield defined.
Flexible::make('Fields')
->addLayout('Simple content section', 'wysiwyg', [
Text::make('Title'),
])
->addLayout('Video section', 'video', [
Text::make('Title'),
// Sub Flexible Layout
Flexible::make('Fields')
->addLayout('Simple content section', 'wysiwyg', [
Text::make('Title'),
])
->addLayout('Video section', 'video', [
Text::make('Title'),
])
])
For example:
Thank you!
First of all congratulation for the plugin, amazing work!
Do you have any plans supporting multilingual packages like spatie Nova Translatable?
I've tried it but it's not compatible
Thank you
It could be useful to be able to limit the amount of times a layout can be added to the flexible field.
For example, if the field is used as a replacement for the BelongsToMany field, it is necessary to limit to 1 the amount of times a layout can be added, as adding 2 of the same layout is going to cause the first one to be overriden by the second one.
Another, maybe simpler example:
We have a Flexible field to allow the user to construct their About page with predefined sections. But maybe we want to limit the Contact info
section to only appear once on the page. If the user has already added a Contact info
section, the option would then be either removed or greyed out from the list when adding a new layout, maybe with a helpful tooltip message explaining that they have exceeded the maximum amount this section allows.
Hello,
how can I use DateTime field (i can not use it in Preset).
Or am I doing something wrong?
Thank you
When having a 409 Conflict
Error on Nova the progressed Response is not typed as a JsonResponse.
Because of this we get a Server Error
message instead of the "Another user edited this" message.
The resulting error is:
Argument 1 passed to Whitecube\NovaFlexibleContent\Http\Middleware\InterceptFlexibleAttributes::transformFlexibleErrors() must be an instance of Illuminate\Http\JsonResponse, instance of Illuminate\Http\Response given
which can be solved by changing the type hint in TransformFlexibleErrors
line 9 from JsonResponse
to only Resonse
.
I assume this can run into new issues with line 22 as setData
is possibly not available if this is really not an JsonResponse... so there could/should be a type check before!?
Hi there,
This looks like a great package - just wondering if anyone has had any luck getting Spatie's Media Library working with the Nova Media Library package? If not, can anyone suggest a place to start in getting these two packages working with flexible content nicely?
Thanks!
I think this might be a false positive, had a quick glance at the code and everything seemed alright. But just so you are aware using larastan (default config) I always get this message:
Call to method addLayout() on an unknown class Whitecube\NovaFlexibleContent\this.
Cheers. (amazing package, btw!)
when i save my resource i expect the flexible to save like that:
[{"layout":"links","key":"112be2b576879837","attributes":{"title":"eARO","link":"https://www.test.com/"}},
{"layout":"links","key":"a0mtwyx2jrtwaou2f3jlo-links","attributes":{"title":"eAIP","link":"https://www.test2.com/"}}]
but when i save the flexible i get this:
[{"layout":"links","key":"112be2b576879837","attributes":{"112be2b576879837__112be2b576879837__title":"eARO","112be2b576879837__112be2b576879837__link":"https://www.test.com/"}},{"layout":"links","key":"a0mtwyx2jrtwaou2f3jlo-links","attributes":{"a0mtwyx2jrtwaou2f3jlo-links__a0mtwyx2jrtwaou2f3jlo-links__title":"eAIP","a0mtwyx2jrtwaou2f3jlo-links__a0mtwyx2jrtwaou2f3jlo-links__link":"https://www.test2.com/"}}]
Now i know the problem is here when i use NovaDependencyContainer:
public function fields(Request $request) {
return[
NovaDependencyContainer::make([
Flexible::make('Value')->addLayout('Links', 'links', [
Text::make('Title'),
Text::make('Link'),
]),
])->dependsOn('type', 'outer_FE_links_array'),
];
}
if i just use the flexible field as an normal field it works:
public function fields(Request $request) {
return[
Flexible::make('Value')->addLayout('Links', 'links', [
Text::make('Title'),
Text::make('Link'),
]),
];
}
any suggestions how to solve that ?
In resources/js/components/FormField.vue
we have the line:
<div v-if="isLayoutsDropdownOpen" class="overflow-hidden absolute rounded-lg shadow-lg max-w-full mb-3 pin-b max-h-search overflow-y-auto border border-40">
Which contains overflow-hidden
and overflow-y-auto
, which limits the list to the last 3 layouts.
I completely understand not wanting to overflow off the screen, or even over/under UI elements, but this is strangely limiting, and not even scrollable. I'm surprised no one else has hit this issue.
If no one has any issues with just removing the overflow classes, I'll push a PR for this.
Would be good for docs to make it clear the best way to go about accessing the data stored from the flexible fields in views.
I am using this package with the whitecube/nova-page. It would be very nice to combine these two. If this is already done, please provide some docs.
For example i have flexible content named Slider.
Inside the view i can do Page::get('slider')
this returns the flexible content as a json string. It would be great if i could use something like Page::flexible('slider')
or Page::block('slider')
Hello,
Would it be possible to set the default number of flexible fields to be displayed on page load? For example setting something like ->initiallyVisible(2) would pre-add 2 instances of the field on the page initialization?
Kind of like what this does package does.
Please tell me, is it possible to create a form for several entities using this package?
For example, Books and Authors?
Hi all! First of all; thanks for the amazing package!
We're trying to get this package to work with https://github.com/DigitalCloud/multilingual-nova, which gives us a language selector for the entire Nova resource.
I've seen a couple issues suggesting mrmorat's translatable fields inside the flexible layout. Sadly I need to make the entire field translatable so different locales may have a different combination of flexible layouts.
Using the suggested package by mrmonat we would also have to select a language for each translatable field inside the layout. Using this in conjunction with the aforementioned multilingual-nova package doesn't make much sense from a UX consistency standpoint.
Is there any other way to get this to work? Any help is much appreciated!
It could be nice to be able to collapse existing layout instances to make them take less space in the page if we're not currently editing them.
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.