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:
Full solution is ``` Repeater::make('contents') ->relationship('contents', modifyQueryUsing: fn ($query) => $query->where('language', 'en')) ->schema([ RichEditor::make('description') ])...
Jump to solution
38 Replies
toeknee
toeknee2mo ago
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); }
mile4841
mile48412mo ago
No it is in resource, do you have idea how i can add it there
toeknee
toeknee2mo ago
if it's in a resource and you are editing it'll be filled from the record
mile4841
mile48412mo ago
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; })
toeknee
toeknee2mo ago
So add it as a relationship
mile4841
mile48412mo ago
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?
toeknee
toeknee2mo ago
Are you a laravel developer? If you add a relationship to the table it references then you can render it with myrelationship.description
mile4841
mile48412mo ago
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')
toeknee
toeknee2mo ago
->default('my value') for creation only
mile4841
mile48412mo ago
on mine edit resource still nothing
No description
toeknee
toeknee2mo ago
Edit will fill from it's values if you are editing the record should have a value hence why I said for creation only
Dennis Koch
Dennis Koch2mo ago
@mile4841 Can you please read our #✅┊rules for proper code formatting.
mile4841
mile48412mo ago
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
Dennis Koch
Dennis Koch2mo ago
RichText doesn't support relations. You can use a Layout field as a wrapper. What kind of relation is this?
mile4841
mile48412mo ago
hasMany
Want results from more Discord servers?
Add your server