#What can I use instead of Placeholder in version 4?
14 messages · Page 1 of 1 (latest)
TextEntry with ->state()
thanks.That work fine for text input fields. But I also have a question how can I embedded html from rich editor? for example -> description is from rich editor and that code not working.
TextEntry::make('review_description')
->label('Description')
->state(fn ($get) => $get('description')),
@glass tusk
?
RichEditor::make('description')
->live(onBlur: true),
TextEntry::make('review_description')
->state(fn (Get $get) => $get('description'))
->html()
In my case the code was:
Placeholder::make('')->columnSpan(1),
Used to insert an space between a 2 columns component and a 1 column one.
I don't find a way to substitute it.
TextEntry::make(' ')->state(' ')->columnSpan(1)
Requires make and state to have non empty values.
And if I put values on them they show in the form.
the solution is using TextEntry with state
for example ->
TextEntry::make('my_entry')
->state(fn(Get $get) => $get('my_entry')),
I actually got burned by this answer. TextEntry doesn't pass the data, and Placeholder does. So for any cases where you depend on data being passed through to your form or action, just know that TextEntry doens't work.
it isn't optimal but you could always use a custom field which does nothing but display some blade
or make a custom field which mimics the old placeholder behavior
@pastel valve What do you mean with "doesn't pass the data"? The following is working:
TextEntry::make("name")
->formatStateUsing(fn($state) => $state),
TextEntry::make("infotext")
->formatStateUsing(fn($get) => $get("country_id")),
I mean that when I use it for actions and dump the $data attribute, those 'name' and 'infotext' values would not be included with the rest of the data.
If you want to pass a value through to a form, the best I've found is a combination of textEntry and Hidden:
Hidden::make("name"),
TextEntry::make("name"),