Required and Disabled with condition in TextArea are not working

I have radiodeck plugin and textarea in my form
RadioDeck::make('is_status')
->label('Status')
->options([
'0' => 'No',
'1' => 'Yes',
])
->descriptions([
'0' => 'Record with status Non-Active',
'1' => 'Data with status Active',
])
->default(0)
->required()
->alignment(Alignment::Start)
->color('primary')
->extraCardsAttributes([
'class' => 'rounded-xl',
])
->live()
->columns(2)
->columnSpanFull()
->afterStateUpdated(function (?string $state, ?string $old, callable $set) {
if ($old) {
$set('description', null);
}
}),
Forms\Components\Textarea::make('description')
->label('Description')
->required(fn (callable $get): bool => $get('is_status'))
->disabled(fn (callable $get): bool => !$get('is_status'))
->rows(5)
->autosize()
->extraInputAttributes([
'oninput' => 'this.value = this.value.toUpperCase()',
'required' => false,
])
->dehydrateStateUsing(fn (?string $state) => $state ? strtoupper($state) : '')
->columnSpanFull(),
RadioDeck::make('is_status')
->label('Status')
->options([
'0' => 'No',
'1' => 'Yes',
])
->descriptions([
'0' => 'Record with status Non-Active',
'1' => 'Data with status Active',
])
->default(0)
->required()
->alignment(Alignment::Start)
->color('primary')
->extraCardsAttributes([
'class' => 'rounded-xl',
])
->live()
->columns(2)
->columnSpanFull()
->afterStateUpdated(function (?string $state, ?string $old, callable $set) {
if ($old) {
$set('description', null);
}
}),
Forms\Components\Textarea::make('description')
->label('Description')
->required(fn (callable $get): bool => $get('is_status'))
->disabled(fn (callable $get): bool => !$get('is_status'))
->rows(5)
->autosize()
->extraInputAttributes([
'oninput' => 'this.value = this.value.toUpperCase()',
'required' => false,
])
->dehydrateStateUsing(fn (?string $state) => $state ? strtoupper($state) : '')
->columnSpanFull(),
Even though I have 'disabled' set to false in extraInputAttributes, it is still not functioning as it should. I tweak the necessary rule by setting 'required' to false in extraInputAttributes and it's working fine (without it, it's still have required in textarea even though is_status is set to false). What I want is for the textarea to be disabled while is_status is non-active and to not be disabled when is_status is active note: when I change textarea to textinput, it works as I wanted to be
0 Replies
No replies yetBe the first to reply to this messageJoin