PHP code example of itsimplycom / nova-mcm-repeatable-fields
1. Go to this page and download the library: Download itsimplycom/nova-mcm-repeatable-fields library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itsimplycom / nova-mcm-repeatable-fields example snippets
namespace App\Nova;
use Fourstacks\NovaRepeatableFields\Repeater;
// ...
class Petstore extends Resource
{
// ...
public function fields(Request $request)
{
return [
// ...
Repeater::make('Dogs'),
// ...
];
}
}
namespace App;
// ...
class Petstore extends Model
{
protected $casts = [
'dogs' => 'array'
]
}
Repeater::make('Dogs')
->addField([
// configuation options
])
[
'label' => 'Dog name',
//...
]
[
'name' => 'dog_name',
//...
]
[
'type' => 'number',
//...
]
[
'placeholder' => 'Name that dog',
//...
]
[
'width' => 'w-1/2',
//...
]
[
'options' => [
'fido' => 'Fido',
'mr_bubbles' => 'Mr Bubbles',
'preston' => 'Preston'
]',
//...
]
Repeater::make('Dogs')
->addButtonText('Add new dog');
Repeater::make('Dogs')
->summaryLabel('Dogs');
Repeater::make('Dogs')
->displayStackedForm();
Repeater::make('Dogs')
->initialRows(4);
Repeater::make('Dogs')
->maximumRows(4);