z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.13k stars 2.81k forks source link

How to show default image in $form->image('avatar') #5752

Closed phuchung2399 closed 1 year ago

phuchung2399 commented 1 year ago

Description:

I would like to show default image in $form->image('avatar').

Now I can not show default image when I create new record. image

I want to show image

Please help me, thanks.

gomes2191 commented 1 year ago

Explain in more detail what you really want.

phuchung2399 commented 1 year ago

Explain in more detail what you really want.

Yes. I want to show default image when each of us create something new when using Form.

For example, I want to create a new user. When I click the create button, $form->image('avatar') will automatically display an image that I have defaulted.

It will look like this: image

I can't currently assign a default value to $form->image('avatar').

I have tried using: $form->image('avatar')->default('image-url') $form->image('avatar')->value('image-url')

however it doesn't work image

-- Please help me, thanks.

styq123 commented 1 year ago

hey,bro

$form->image('index', __('图片上传'))->attribute('data-initial-preview', $url);

phuchung2399 commented 1 year ago

hey,bro

$form->image('index', __('图片上传'))->attribute('data-initial-preview', $url);

Thanks bro. I have resolved issue with your solution.