Sebastian Hilger
Sebastian Hilger

I'm stuck with the repeater widget. It is easy enough to create it in the form, but how can I save the fields for example to a hasMany relation? It would be nice to have a littel demonstration. Thanks!

d.negativa
d.negativa

Add jsonable type for your "repeater" fild in your model:


namespace  Acme\PluginName\Models;
use Model;
class Item extends Model
{
    protected $jsonable = ['your_repeater_field_name']; 

and add json type for your "repeater" fild in your migration:


namespace Acme\PluginName\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateItemsTable extends Migration
{

    public function up()
    {
        Schema::create('acme_pluginname_items', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('name')->nullable();
            $table->string('slug')->index();
            $table->json('your_repeater_field_name');  
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('acme_pluginname_items');
    }

}

Last updated

Sebastian Hilger
Sebastian Hilger

Wow - thank you for this swift and absolutely helpful reply!

hjfigueira
hjfigueira

Hi, is possible to save the repeater records in related records instead of a json field ? If is, could any snippet be provided ? Thanks.

Renatio
Renatio

No, it is not possible. You should use relation manager for that.

raakesh
raakesh

How can I display repeater data in backend column lists?

1-6 of 6