laravel / nova-issues

556 stars 34 forks source link

Delete in repeater field is not working properly #5786

Closed sirish-amatya closed 1 year ago

sirish-amatya commented 1 year ago

Description:

When i try to delete the repeater field items it deletes the items on that index, which is expected, along with other items after that index.

https://github.com/laravel/nova-issues/assets/32788937/b672af75-4922-43a0-84a0-7496340c9b97

Detailed steps to reproduce the issue on a fresh Nova installation:

  1. Register a repeater field with hasMany preset in a Resource as below
  2. Add few records
  3. Delete the second last record
//Resource Class
use App\Nova\Repeater\Email;

public function fields(NovaRequest $request)
{
        return [
            Repeater::make('Emails', 'emails')
                ->asHasMany()
                ->uniqueField('id')
                ->repeatables([
                    Email::make()
                ])
        ];
}
//Repeater Class

class Email extends Repeatable
{
    /**
     * The underlying model the repeatable represents.
     *
     * @var class-string
     */
    public static $model = ResourceModel::class;

    /**
     * Get the fields displayed by the repeatable.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::hidden('id'),
            Text::make('Email', 'value'),
            Boolean::make('Verified'),
            Boolean::make('Is Primary')
        ];
    }
}
github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.