ngaiza_287
CheckboxList not passing data
Hello, i have search the docs but i cant seem to be able to selected items from the CheckBoxList. I have it nested in a wizard. All other fields data are coming through but i cant get data from the CheckboxList
1 replies
repeater field test
please assist, am trying to check if a field in the repeater can through error if not available, and how i can use file in pest test to fill the field for testing. Here is a rough idea of what am trying to do.
The class
class Add extends Component implements HasForms
{
use InteractsWithForms;
public $name = '';
public $phone_number = '';
protected function getFormSchema(): array
{
return [
TextInput::make('name')
->label('Full name')
->required(),
Repeater::make('phones')
->relationship()
->schema([
TextInput::make('phone_number')
->label('Phone Number')
->hint('E.g: 255713001001 or 0713001001')
->required(),
])
->label('Phone numbers')
->defaultItems(1)
->minItems(1)
->createItemButtonLabel('Add user phone number'),
];
}
}
The test
livewire(Add::class)
->call('invite')
->assertHasErrors(['name', 'phone_number']);
4 replies
Get Relationship Value in Table Action from Form
Hello, Am trying to get a value of a relationship field in table action from action form. I cant seem to get it of $data array.
Action::make('add')
->label('Add Results')
->icon('heroicon-s-plus-circle')
->color('warning')
->form([
Select::make('exam_id')
->label('Examination')
->options(Exam::all()->pluck('name', 'id'))
->required(),
Select::make('subject_id')
->label('Subject')
->relationship('subjects', 'name')
->hint('Please select only one subject')
->multiple()
->required()
->preload(),
])->action(function (Model $record, array $data): string {
$subject = $data['subject_id']; // I need to get this value
dd($subject);
return redirect()->route('results.record', [
'grade' => $record,
'exam' => $data['exam_id'],
'subject' => $data['subject_id']
]);
}),
5 replies