In my form, I have several select, all the same name, but different Ids.
<form method="POST" action="/"
accept-charset="UTF-8">
<select name="directElimination_fighters[]" class=directElimination_select id="1_1">
<option selected></option>
<option value="1639"> Esteban Prohaska </option>
<option value="1640"> Vicenta Walsh </option>
</select>
<select name="directElimination_fighters[]" class=directElimination_select id="1_2">
<option selected></option>
<option value="1639"> Esteban Prohaska </option>
<option value="1640"> Vicenta Walsh </option>
</select>
<button type="submit" class="btn btn-success" id="update">
Update
</button>
</form>
I'm making my functional tests, so I do :
$this->visit('/')
->select('Esteban Prohaska', '1_2')
->press('update');
But PHPUnit says:
InvalidArgumentException: Unreachable field "1_2"
When I add ->dump()
, I can see in HTML the id="1_2" field. So what's wrong with my code???
答案 0 :(得分:1)
您遗失了#
- #1_2 。就像在CSS中一样,标识符以#。
$this->visit('/')
->select('#1_2', 'Esteban Prohaska')
->press('update');
默认情况下,Laravel会将->select()
的第一个参数视为输入名称。
答案 1 :(得分:1)
将其更改为:
->select('#1_2', '1639')