栗まんじゅう
栗まんじゅう
TCTwill CMS
Created by 栗まんじゅう on 4/13/2025 in #👊support
Inline-Repeater & Medias
How can i use Form Builder Inline-Repeater with Medias field? I tried to implement it like this:
$form->addFieldset(
Fieldset::make()->title('Key Visual (Banners)')->id('key_visual')->fields([
InlineRepeater::make()
->name('key_visuals')
->label('Key Visuals')
->fields([
Medias::make()->name('image')->label('Key Visual (Banner)'),
Checkbox::make()
->name('cta_external')
->label('Open in New Tab')
->default(false),
Input::make()->name('cta_link')->label('CTA Link'),
]),
Input::make()->type('number')->min(0)->step(0.1)->name('autoplay_delay')->label('Autoplay Delay (in second)')->placeholder('e.g. 2.5'),
]),
);
$form->addFieldset(
Fieldset::make()->title('Key Visual (Banners)')->id('key_visual')->fields([
InlineRepeater::make()
->name('key_visuals')
->label('Key Visuals')
->fields([
Medias::make()->name('image')->label('Key Visual (Banner)'),
Checkbox::make()
->name('cta_external')
->label('Open in New Tab')
->default(false),
Input::make()->name('cta_link')->label('CTA Link'),
]),
Input::make()->type('number')->min(0)->step(0.1)->name('autoplay_delay')->label('Autoplay Delay (in second)')->placeholder('e.g. 2.5'),
]),
);
it can successfully save sth like medias: {…somedata} inside the inline-repeater json columns & also role key_visuals|0|image in twill_mediables table, But when i reload the form, it cannot retrieve the image and show it on the Medias field, other input fields in the json columns works perfectly fine except the Medias field, I don’t know how to add to $mediasParams in the Model so i leave it blank, I added ‘key-visuals’ => ‘array’ into $cast already,
protected $casts = [
'key_visuals' => 'array',
];
}
protected $casts = [
'key_visuals' => 'array',
];
}
I did the same setup of HandleJsonRepeaters in the HomepageRepository.php same as other working modules (InlineRepeater without Medias)
use HandleTranslations, HandleMedias, HandleJsonRepeaters;

protected $jsonRepeaters = ['key_visuals'];
use HandleTranslations, HandleMedias, HandleJsonRepeaters;

protected $jsonRepeaters = ['key_visuals'];
Anyone know how to modify the Controller / Model of my module in order to make this work? Or Medias is just not well-supported for Inline-Repeater at this point?
1 replies