shisui#00000
FileUpload on edit page
Here's a code snippet that creates the repeater images for ref:
public static function getRandomImageSchema(array $options = []): array
{
return [
Hidden::make('id'),
TextInput::make('label')
->maxLength(70)
->default(null)
->disabled($options['disabled'] ?? false)
->required(),
Repeater::make('images')
->disabled($options['disabled'] ?? false)
->collapsed()
->itemLabel(function ($uuid, $component) {
$keys = array_keys($component->getState());
$index = array_search($uuid, $keys);
return "Image " . $index + 1;
})
->addActionLabel('Add another image')
->maxItems(4)
->schema([
TextInput::make('name')
->label('image name')
->maxLength(100)
->required(),
FileUpload::make('background_image_url')
->label('Square thumbnail') ->label('logo') ->disk('s3')
->image()
->imageEditorViewportWidth(428)
->imageEditorViewportHeight(172)
->reorderable()
->appendFiles()
->maxSize(51200)
->panelLayout('integrated')
->directory('media/images')
->visibility('publico')
->uploadProgressIndicatorPosition('left')
->reactive(),
TextInput::make('background_image_alt_text')
->label('Image alt text') ->maxLength(50) ->required()
->visible(fn($get) => !empty($get('background_image_url'))),
]),
];
}
35 replies