Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
PHPUnit testing dynamically created form elements

I am writing phpunit tests for a form. In my form, I dynamically created array input elements with jquery. However, I cannot find a way to interact with these dynamic elements in phpunit. I am consistently getting InvalidArgumentException: Unreachable field "", because my form does not contain these elements (till jquery creates them).

I am using Laravel 5.3. Any suggestions?

Dynamically created element:

<fieldset class="package">
  <div class="form-group" style="padding-bottom: 30px;">
    <section>
    <label class="label control-label col-md-1" style="padding-top: 7px;">Pallet</label>
      <div class="col-md-11"><label class="input">
      <div class="input-group">          
      <input value="1234" type="text" name="package_barcode[]" text="1234">
      <input value="Pallet" type="hidden" name="package_type[]">
      <div class="input-group- btn"> <button class="btn-inline btn-danger remove_package" type="button">Cancel Package </button> </div>
      </div>
      </label>  
      </div>
    </section>
  </div>
</fieldset>

Phpunit test:

public function testFormSuccess()
{
    $input = [
        'package_type[]' => 'Box',
        'package_barcode' => 1
    ];

    $this->actingAs($this->getUser())
        ->visit('/new')
        ->submitForm('submit', $input)
        ->seePageIs('/');
}
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!