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

multiple_upload field doesn't allow delete in update view. #2190

Closed
justinmoh opened this issue Nov 1, 2019 · 2 comments
Closed

multiple_upload field doesn't allow delete in update view. #2190

justinmoh opened this issue Nov 1, 2019 · 2 comments
Labels

Comments

@justinmoh
Copy link

Bug report

What I did

CRUD::addField(
    [
        'label' => 'Extra Photos',
        'name' => 'extra_photos',
        'type' => 'upload_multiple',
        'upload' => true,
        'wrapperAttributes' => [
            'class' => 'form-group col-md-6',
        ],
    ]
);

What I expected to happen

The CRUD field appears and works across CRUD.

What happened

In update view, when you click the cross X beside the file name to mark it as delete, it doesn't work properly -- it doesn't trigger the relevant JS functions.

What I've already tried to fix it

The problem happens to be in the view file:

@php
    if (!isset($field['wrapperAttributes']) || !isset($field['wrapperAttributes']['class']))
    {
        $field['wrapperAttributes']['data-init-function'] = 'bpFieldInitUploadMultipleElement';
        $field['wrapperAttributes']['data-field-name'] = $field['name'];
    }
@endphp

Instead of merging, it skips loading of upload field init function when you have wrapperAttributes. So I manually add this two line into my code, and that avoid the bug -- yet I still think this is a bug.

        // in my EntityCrudController 
        'wrapperAttributes' => [
            'class' => 'form-group col-md-6',
            'data-init-function' => 'bpFieldInitUploadMultipleElement',
            'data-field-name' => 'extra_photos',
        ],

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### LARAVEL VERSION:
laravel/framework                     v6.4.0   The Laravel Framework.

### BACKPACK VERSION:
backpack/crud                         4.0.12   Quickly build an admin int...
backpack/generators                   2.0.4    Generate files for laravel...
backpack/logmanager                   3.0.0    An interface to preview, d...
@welcome
Copy link

welcome bot commented Nov 1, 2019

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

@justinmoh
Copy link
Author

Looks like this issue have already reported in #2188 . My report will stay here as it includes sample solution code for those who have no clue fixing this, but i'll close this for good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant