F
Filament2d ago
Anik

radio button null value

Hello can i have null value as an radio option like we have on a select option (placeholder) value? something that would provide the html functionality below
<form>
<fieldset>
<legend>Please select your preferred contact method:</legend>
<div>
<input type="radio" id="contactChoice1" name="contact" value="email" />
<label for="contactChoice1">Email</label>
<input type="radio" id="contactChoice2" name="contact" value="phone" />
<label for="contactChoice2">Phone</label>
<input type="radio" id="contactChoice3" name="contact" value="null" />
<label for="contactChoice3">Null</label>
</div>
<div>
<button type="submit">Submit</button>
</div>
</fieldset>
</form>
<pre id="log"></pre>
<form>
<fieldset>
<legend>Please select your preferred contact method:</legend>
<div>
<input type="radio" id="contactChoice1" name="contact" value="email" />
<label for="contactChoice1">Email</label>
<input type="radio" id="contactChoice2" name="contact" value="phone" />
<label for="contactChoice2">Phone</label>
<input type="radio" id="contactChoice3" name="contact" value="null" />
<label for="contactChoice3">Null</label>
</div>
<div>
<button type="submit">Submit</button>
</div>
</fieldset>
</form>
<pre id="log"></pre>
Forms\Components\Radio::make('contact_preference')
->label(__('Choose Plan'))->columnSpanFull()
->options([
'email' => 'Email',
'phone' => 'Phone',
null => 'No preference'
])
Forms\Components\Radio::make('contact_preference')
->label(__('Choose Plan'))->columnSpanFull()
->options([
'email' => 'Email',
'phone' => 'Phone',
null => 'No preference'
])
the radio component doesnt select No preference when data has null value on mounted, but works correctly when saved
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?