CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

[Bug] When select2 and repeatable are used together, both doesn't work

Open ankitnykaa2029 opened this issue 2 years ago • 2 comments

Bug report

I wrote the following code

$this->crud->addField([ 'label' => 'Store', // Label for HTML form field 'type' => 'select2', // HTML element which displaying transactions 'name' => 'store_id', // Table column which is FK for Customer table 'entity'=> 'store', // Function (method) in Customer model which return transactions 'attribute' => 'name', // Column which user see in select box 'model' => Store::class // Model which contain FK ]);

$this->crud->addField([ 'name' => 'banners', 'label' => 'Add Banners', 'hint' => 'Add the banners in the order you want them to show.', // helpful text, shows up after the input 'type' => 'repeatable', 'subfields' => [ [ 'name' => 'title', 'label' => 'Title', 'type' => 'emoji', 'hint' => '35 characters limit', 'attributes' => [ 'maxlength' => '35', ], ], [ 'label' => 'Media', // Label for HTML form field 'type' => 'select2_from_array', // HTML element which displaying transactions 'name' => 'banner_media_id', // Table column which is FK for Customer table 'options' => ["" => "Select Media"]+$media_banner_array, 'allows_null' => false ], ] ]);

What I expected to happen

The 1st input should be a select2 type of input and the repeatable should work

What happened

The 1st input is converted to normal select and repeatable is not working i.e upon clicking the Add New, nothing happens

What I've already tried to fix it

When I put the repeatable input first, and the select2 at 2nd number, then it works fine.

Is it a bug in the latest version of Backpack?

After I run composer update backpack/crud the bug... is it still there?

Backpack, Laravel, PHP,DB version

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

PHP VERSION:

PHP 8.2.11 (cli) (built: Oct 6 2023 09:47:18) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.11, Copyright (c) Zend Technologies with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies

LARAVEL VERSION:

v9.52.16@082345d76fc6a55b649572efe10b11b03e279d24

BACKPACK PACKAGE VERSIONS:

backpack/crud: 5.6.1 backpack/generators: v3.3.17 backpack/permissionmanager: 6.0.17 backpack/pro: 1.0.9

ankitnykaa2029 avatar Oct 27 '23 12:10 ankitnykaa2029

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 channels:

  • 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;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

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

welcome[bot] avatar Oct 27 '23 12:10 welcome[bot]

Hi @ankitnykaa2029 For repeatable working with "select2" you need to call "select2" JavaScript after "Add more" row function. Please let us know if this helps. I also faced same issue earlier but sorted that by calling "select2" Javascript on "Add more" button function.

munjaldevelopment avatar Nov 08 '23 08:11 munjaldevelopment

Closing due to inactivity. Let us know if it's still a problem and we'll reopen.

tabacitu avatar Jun 04 '24 06:06 tabacitu