Schema::create('form_fields', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('form_id');
$table->string('name', 255);
$table->string('rules', 255);
});
class Field extends Model
{
protected $table = 'form_fields';
protected $casts = ['rules' => 'json'];
}
md5-d08f03c26dad006e357941e93069c87b
class FormBuilderController extends \Illuminate\Routing\Controller
{
protected function form()
{
return Admin::form(BuilderForm::class, function (Form $form) {
$form->hasMany('fields', function(NestedForm $nestedForm) {
//this field is getting and storing successfully
$nestedForm->text('name');
//this embed field is ignoring...
$nestedForm->embeds('rules'), function($form){
$form->switch('test');
});
});
});
}
}
same problem
workaround
Admin/Extensions/NestedEmbeds.php
<?php
namespace App\Admin\Extensions;
use Encore\Admin\Form\EmbeddedForm;
use Encore\Admin\Form\Field\Embeds;
class NestedEmbeds extends Embeds
{
protected $view = 'admin::form.embeds';
protected function buildEmbeddedForm()
{
$form = new EmbeddedForm($this->elementName);
$form->setParent($this->form);
call_user_func($this->builder, $form);
$form->fill($this->getEmbeddedData());
return $form;
}
}
Admin/bootstrap.php
Encore\Admin\Form::extend('nestedEmbeds', \App\Admin\Extensions\NestedEmbeds::class);
class FormBuilderController extends \Illuminate\Routing\Controller
{
protected function form()
{
return Admin::form(BuilderForm::class, function (Form $form) {
$form->hasMany('fields', function(NestedForm $nestedForm) {
//this field is getting and storing successfully
$nestedForm->text('name');
//this embed field is ignoring...
$nestedForm->nestedEmbeds('rules'), function($form){
$form->switch('test');
});
});
});
}
}
@shinbashi
Worked fine!! Nice!
@shinbashi Thanks, man!
Most helpful comment
workaround
Admin/Extensions/NestedEmbeds.php
Admin/bootstrap.php