Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Properties not saving vaules #50

Closed
cyclops1101 opened this issue Jan 16, 2019 · 5 comments
Closed

Custom Properties not saving vaules #50

cyclops1101 opened this issue Jan 16, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@cyclops1101
Copy link

I've tried using the custom property field as the documentation presents but it won't save any values. If the property doesn't already exist it will create the key but it will only ever set it to null

Images::make('Image') ->customPropertiesFields([ Boolean::make('Active'), Markdown::make('Description'), ])

In addition the custom property popup doesn't block the keyup detection on the detail page, meaning if I open the popup on the detail page and try to type into a field it navigate to the edit view when an e is pressed. Not sure if you'd want to remove the popup on the detail page altogether or override that keyup event.

@ebess ebess added the bug Something isn't working label Jan 16, 2019
@litalboa
Copy link

@ebess there is a solution to this?

@ebess
Copy link
Owner

ebess commented Apr 18, 2019

@cyclops1101 @litalboa

The detailview is not the proper place to edit some data on the product / products media imo. All custom properties are not saved by clicking the update button on the modal. You need to update/create the whole model.

Beside that, do custom properties work as expected on the edit view?

Will remove the edit custom properties icon from detail view.

ebess added a commit that referenced this issue Apr 18, 2019
- removed custom properties icon from detail view
@ebess ebess closed this as completed Apr 18, 2019
@cyclops1101
Copy link
Author

I still can't get the custom property fields to hydrate nor save when I use the form fields.

@cyclops1101
Copy link
Author

Looking at the HandlesCustomPropertiesTrait the fillMediaCustomPropertiesFromRequest method doesn't interact with the media object. Adding the code below into the foreach loop got the media model to update appropriately.

$value = $request->{$collection . "-custom-properties"}[$index][$field->attribute];
$media->setCustomProperty($field->attribute,
$field->component === 'boolean-field' ? !!$value : $value);

@glebihan
Copy link

In case someone else faces this issue, I've noticed that the current code is only compatible with Laravel >= 5.7.
Setting custom properties on Laravel 5.6 won't work. This is the commit involved : laravel/framework@1fa9459

Gompje pushed a commit to DaktaDeo/advanced-nova-media-library that referenced this issue Mar 29, 2024
- removed custom properties icon from detail view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants