Dynamic Form Inside Repeater isn't reactive

Select::make('type')
->required()
->default(QrContentType::Text)
->options(QrContentType::class)
->live(),
Repeater::make('payload')
->hiddenLabel()
->schema(function (Get $get) {
/** @var QrContentType $type */
$type = $get('type') ?? QrContentType::Text;

return $type->toForm();
})
->deletable(false)
->addable(false)
->reorderable(false)
->live(),
Select::make('type')
->required()
->default(QrContentType::Text)
->options(QrContentType::class)
->live(),
Repeater::make('payload')
->hiddenLabel()
->schema(function (Get $get) {
/** @var QrContentType $type */
$type = $get('type') ?? QrContentType::Text;

return $type->toForm();
})
->deletable(false)
->addable(false)
->reorderable(false)
->live(),
class UrlSchema
{
/**
* @return array<int, Field>
*/
public static function getForm(): array
{
return [
Toggle::make('is_dynamic_qr')
->live()
->afterStateUpdated(function () {
\Log::debug(Str::random());
})
->helperText('Enabling this will create a QR code that points to an internal short link, which will redirect to any specified link, dynamically. Once you generate the QR code, make sure to never update the short link alias, or else the QR will stop working.'),
TextInput::make('link')
->required()
->hidden(fn (Get $get) => $get('is_dynamic_qr')),
Select::make('link')
->required()
->visible(function (Get $get) {
\Log::debug($get('payload'));
\Log::debug($get('is_dynamic_qr'));

return $get('is_dynamic_qr');
}),
];
}
}
class UrlSchema
{
/**
* @return array<int, Field>
*/
public static function getForm(): array
{
return [
Toggle::make('is_dynamic_qr')
->live()
->afterStateUpdated(function () {
\Log::debug(Str::random());
})
->helperText('Enabling this will create a QR code that points to an internal short link, which will redirect to any specified link, dynamically. Once you generate the QR code, make sure to never update the short link alias, or else the QR will stop working.'),
TextInput::make('link')
->required()
->hidden(fn (Get $get) => $get('is_dynamic_qr')),
Select::make('link')
->required()
->visible(function (Get $get) {
\Log::debug($get('payload'));
\Log::debug($get('is_dynamic_qr'));

return $get('is_dynamic_qr');
}),
];
}
}
11 Replies
Eskie
EskieOP4w ago
So when i change the type from Text to Url.. the newly generated form isn't reactive.. is it only reactive if the default value of type is Url I discovered that Toggle component doesn't work on repeater if the form is dynamic
Eskie
EskieOP4w ago
Thanks for the suggestion, anyway I already fixed it by changing the Component from Toggle to Checkbox.. i think it is a bug on Toggle component
LeandroFerreira
you could create a minimal repo on github to reproduce the issue. I can take a look
Eskie
EskieOP4w ago
sure i will update you..
Eskie
EskieOP4w ago
GitHub
GitHub - khalidmaquilang/test-toggle-dynamic-form
Contribute to khalidmaquilang/test-toggle-dynamic-form development by creating an account on GitHub.
Eskie
EskieOP4w ago
here is the minimal repo for the current situation
LeandroFerreira
bug I think 🤔
Eskie
EskieOP4w ago
oh i see.. another step for being the best! looking forward for the fix.. should i remove the repo now?
LeandroFerreira
you can
Eskie
EskieOP4w ago

Did you find this page helpful?