laravel / nova-issues

556 stars 34 forks source link

Repeater field doesn't work with certain validation rules #6395

Open ecreeth opened 6 months ago

ecreeth commented 6 months ago

Description:

I've been facing some inconsistencies with the following validation rules:

  1. gt:rule
  2. lt:rule

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

  1. Create a Repeatable field

    class LineItem extends Repeatable
    {
    public function fields(NovaRequest $request)
    {
        return [
            ID::hidden(),
    
            Currency::make('Price')
                ->min(1)
                ->step(0.01)
                ->fullWidth()
                ->rules('required', 'numeric', 'gt:cost'),
    
            Currency::make('Cost')
                ->min(1)
                ->step(0.01)
                ->fullWidth()
                ->rules('required', 'numeric', 'lt:price'),
        ];
    }
    }
  2. Call the repeatable

    Repeater::make('Presentations')
    ->required()
    ->sortable(false)
    ->uniqueField('id')
    ->asHasMany(Presentation::class)
    ->repeatables([
      LineItem::make()->confirmRemoval(),
    ]),
  3. Add 500 to the price and 250 to the cost like: image

crynobone commented 6 months ago

Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

ecreeth commented 6 months ago

Hi @crynobone!, Here's the repo link with the bug https://github.com/ecreeth/nova-issue. You can see it too in the video below.

https://github.com/laravel/nova-issues/assets/20761166/71de8a5e-7739-4168-b45c-8cdac00e8251

jeremynikolic commented 3 months ago

@ecreeth Thanks for the reproducing setup, I managed to reproduce the issue and narrow down the cause as well.

To manage expectations, we have short term plans to focus on them and get them out of beta, so we will fix this issue at that time 👍