Level 32
@amirhesam Try the Repeater.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to make a survey with ''adding a form to a Livewire component'' option. each survey has many questions and depending on it's type may have options. I tried using foreach loop in form schema but it's not possible how should I do it?
How I thought it will work:
public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
foreach ($this->survey->questions as $question){
Wizard\Step::make($question->sort)
->label('')
->schema([
if ($question->type == 'text'){
TextInput::make($question->id)
->label($question->text)
->required($question->required)
}elseif ($question->type == 'select'){
Select::make($question->id)
->label($question->text)
->options($question->options->pluck('text','id'))
->required($question->required)
}
]),
}
]),
])
->statePath('data');
}
Please or to participate in this conversation.