How to set value inside of richEditor
Hi i would like to insert a value in richeditor from mine Model, how i can do it for example i want this
RichEditor::make('description')
->value(function(Model $record){
return $record->description;
}),
Solution:Jump to solution
Full solution is ``` Repeater::make('contents')
->relationship('contents', modifyQueryUsing: fn ($query) => $query->where('language', 'en'))
->schema([
RichEditor::make('description')
])...
38 Replies
Is this. in a custom form not a resource
if so on the $form do $form->model($this->record); and in
function mount($id) {
$this->record = MyModel::Find($id);
}
No it is in resource, do you have idea how i can add it there
if it's in a resource and you are editing it'll be filled from the record
the field is from another table in DB, i somehow needs to fill that field like i would do it here Tables\Columns\ImageColumn::make('image')
->label('Image')
->getStateUsing(function (Record $record): string {
return $record->otherTable;
})
So add it as a relationship
You mean like these RichEditor::make('description')
->relationship('contents'), than these is not working, or do you mean i have to make a relation manager?
Are you a laravel developer? If you add a relationship to the table it references then you can render it with myrelationship.description
Okay, i did not ask a good question. How do i insert some value into rich editor? what to add here so i can have some value inside RichEditor::make('description')
->default('my value')
for creation only
on mine edit resource still nothing
![No description](https://cdn.answeroverflow.com/1266036203111579678/image.png)
Edit will fill from it's values
if you are editing the record should have a value
hence why I said for creation only
@mile4841 Can you please read our #✅┊rules for proper code formatting.
Okay., thanks, what then i have to do so it fill mine filed if mine relation is contents and column name is description, what i have to write here in RichEditor::make(here what i should write)
Sorry, i will see
RichText doesn't support relations. You can use a Layout field as a wrapper. What kind of relation is this?
hasMany