Crud: [4.1.0] Repeatable field does not work inside inline create Modal

Created on 2 May 2020  路  8Comments  路  Source: Laravel-Backpack/CRUD

Bug report

Added inline create operation to controller which uses repeatable field

??

Expected json string from the repeatable field to be saved to DB as normal

??

The value for the repeatable field is NULL in the request

??

change repeatable.blade.php line 145 from
element.closest('.modal-content').find('.save-block').click(function(){
to
element.closest('.modal-content').find('#saveButton').click(function(){

This fixes the issue.

??

Backpack, Laravel, PHP, DB version

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

PHP VERSION:

PHP 7.3.16 (cli) (built: Mar 17 2020 13:33:00) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

LARAVEL VERSION:

v7.9.2@757b155658ae6da429065ba8f22242fe599824f7

BACKPACK VERSION:

4.1.x-dev@0f20a3264ca3c56ee095065f36878da1c563c53d

Possible Bug SHOULD

Most helpful comment

Going to close this. AFAIK it's working.

All 8 comments

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

Thanks for taking the time to submit the bug report @coinrese ! I haven't even tested repeatable inside the InlineCreate modal - I've always thought that's best used for smaller forms. But yeah, we should definitely make it work if we can - especially if it's as easy as you say 馃槃

Have you encountered any other issues after this fix?

I don't think this is the proper way to fix this. I think what is happening is that two .modal-content exists and we are getting the wrong one.
But this change is in button selector, so in repeatable you are using #buttonId from inline. Hum ..

Let me have a look before merging this @tabacitu .

@coinrese there were lot's of fixes in inline create etc.

We are able to use repeatable inside the inline-create modal.

Can you composer update backpack/crud and check if it's fixed for you ?

Best,
Pedro

Going to close this. AFAIK it's working.

@pxpm just got around to having another look at this. In my example the value for the repeatable field is still null when submitted from inline create modal...even after composer update.
My backpack version is now 4.1.5@e2c166b065f6b405747db5a5f4d36a2a88f8dc22

if (element.closest('.modal-content').length) { element.closest('.modal-content').find('.save-block').click(function(){ element.val(JSON.stringify(repeatableInputToObj(container))); }) } else if (element.closest('form').length) { element.closest('form').submit(function(){ element.val(JSON.stringify(repeatableInputToObj(container))); return true; }) }

I can't find any reference to the .save-block class in my project, thats why i changed to target the #saveButton. I'm sure this is why the repeatable value is always null in the request when using inline create. The value for the hidden input for the repeatable never gets updated with the json string when its inside a modal.

Still not working for me, latest Backpack 4.1.15@6c751de946a9c8511dd32eb7bfa3ca6a568849f5

Fixed by adding class 'save-block' to Save button in inline_create_modal.blade.php

<button type="button" class="btn btn-secondary" id="cancelButton">{{trans('backpack::crud.cancel')}}</button> <button type="button" class="btn btn-primary save-block" id="saveButton">{{trans('backpack::crud.save')}}</button> </div>

Hello @coinrese and @monoteos

Thank you guys helping to debug this issue.

Sorry for the time it took to solve, but I think now it's fixed for good.

I'v just pushed PR #3302 that would fix this issue. Going to close this so we keep any discussion about this in a single place.

Thanks again, best Pedro

Was this page helpful?
0 / 5 - 0 ratings