I just ran into this issue and tripped upon the answer. I was only able to figure it out by using the Repeater on a new record, then inspecting the entry in the database.
To begin, you want to create a Repeatable such as:
php artisan nova:repeatable ValidationRule
Then you build your Repeatable as shown in the docs. In my case it looked like this:
public function fields(NovaRequest $request)
{
return [
Text::make('Field')->rules('required'),
Text::make('Rule')
];
}
Then, you add that to your resource's list of fields. Something like this, where ruleset is the name of the JSON field on my model:
Repeater::make('Ruleset')
->repeatables([
ValidationRule::make()
])->asJson(),
Now, here's the kicker. If you already have data in the database, you'll need to reformat your JSON field so that each entry is an object with two keys:
-
type which is the kebab form of your Repeatable object's name (mine is not in a subfolder of the Repeater folder, so if yours is, I don't know if that will affect the name).
-
fields which is an object of all your items, keyed by your Repeatable field names
In my case, it looked something like this in the DB:
[{"type":"validation-rule","fields":{"field":"date_of_entry","rule":"date"}},{"type":"validation-rule","fields":{"field":"parent_name","rule":"required, alpha"}}]
Once I manually edited all the model records that already existed, the repeater worked as intended.
Hopefully that helps someone out.