trix values does not get saved
rabol opened this issue · 8 comments
My Model is like this:
class Form extends Model
{
use HasTrixRichText;
protected $fillable = [
'form_id',
'title',
'description',
];
protected $guarded = [];
}
blade like this:
<div class="form-group">
<label class="required" for="content">{{ trans('cruds.form.fields.content') }}</label>
@trix(\App\Form::class, 'content')
@if($errors->has('content'))
<span class="text-danger">{{ $errors->first('content') }}</span>
@endif
<span class="help-block">{{ trans('cruds.form.fields.content_helper') }}</span>
</div>
Controller like this:
$data = $request->all();
$data['form_id'] = NumberSequence::getNextNum('forms');
$form = Form::create($data);
nothing get save to the DB
its is not in my fillable
but... I managed to get it working by adding
form-trixFields to the $fillable
No, it's not fixed, it's a work-around.
According to the documentation one should not add the field to the $fillable
hm... I'll find another solution as $fillable is a 'Laravel' thing I like for security
@amaelftah
Yes please add this to the documentation of this excellent tool.
protected $fillable = ['title', 'post-trixFields', 'attachment-post-trixFields']; // add both trixFields to $fillable
Spent a couple of hours thinking that it didn't work. Many (most?) models will have a $fillable property and any that do won't save the field unless it's added.