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

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

Open
ankitnykaa2029 opened this issue Oct 27, 2023 · 2 comments
Assignees
Labels

Comments

@ankitnykaa2029
Copy link

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

@welcome
Copy link

welcome bot commented Oct 27, 2023

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

@munjaldevelopment
Copy link
Contributor

munjaldevelopment commented Nov 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

4 participants