nova-issues icon indicating copy to clipboard operation
nova-issues copied to clipboard

Repeater field doesn't work with certain validation rules

Open ecreeth opened this issue 9 months ago • 3 comments

  • Laravel Version: ^11.0
  • Nova Version: ^4.33
  • PHP Version: 8.3.2
  • Database Driver & Version: SQLite
  • Operating System and Version: Windows 11
  • Browser type and version: Edge
  • Reproduction Repository: https://github.com/ecreeth/nova-issue

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'),
        ];
    }
}
  1. Call the repeatable
Repeater::make('Presentations')
  ->required()
  ->sortable(false)
  ->uniqueField('id')
  ->asHasMany(Presentation::class)
  ->repeatables([
      LineItem::make()->confirmRemoval(),
]),
  1. Add 500 to the price and 250 to the cost like: image

ecreeth avatar May 17 '24 14:05 ecreeth

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)

crynobone avatar May 20 '24 00:05 crynobone

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

ecreeth avatar May 21 '24 00:05 ecreeth

@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 👍

jeremynikolic avatar Jul 30 '24 07:07 jeremynikolic

Released with Laravel Nova 5.0.0

Feel free to open up a new issue if you're still experiencing this problem on the latest version.

crynobone avatar Dec 16 '24 04:12 crynobone