mercredi 20 mars 2019

How to type in Laravel Dusk with an array of input text?

I have these array of input text :

<input type="text" name="amount[0]">
<input type="text" name="amount[1]">
<input type="text" name="amount[2]">
<input type="text" name="amount[3]">

and I want to type a value using Laravel Dusk. I can't just hardcode using :

$browser->visit('/create')
    ->type('amount[0]', '100')
    ->type('amount[1]', '100')
    ->type('amount[2]', '100')
    ->type('amount[3]', '100');

because the number of input fields depends on the number of items in the database.

I tried using :

$browser->visit('/create')
    ->type('amount[]', '100');

but it doesn't work. Is there a way to achieve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire