Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

birdietorerik's avatar

Cant get any values from my form from controller.

Hi!

Have this controller function -> public function update....

/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Product $product * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $product = $request->productnumber;

      // dump($id);
       dump($product);

}

But in telescope, the dump of $product = null ?

Include my view file, that calls my controller...

@extends('layouts.app')

@section('content')

Endring product & probes
      </span>
    </div>

    <div class="card-body">

@foreach($product['result'] as $indexKey => $prod)

      <form id="formproducts" method="POST" action="/products/{{$prod['product_id']}}">
       
      @method('PATCH')
      @csrf

        <div class="col-sm-12 pb-3">
          <label for="productnumber">Productnumber</label>
          <div class="input-group">
            <div class="input-group-prepend"><span name="prefixproduct" value="21-" class="input-group-text">21-</span></div>
            <input type="text" class="form-control" id="productnumber" name="productnumber" value="{{ $prod['productnumber'] }}" required autocomplete="productnumber" disabled>

            @error('productnumber')
            <span class="invalid-feedback" role="alert">
              <strong>{{ $message }}</strong>
            </span>
            @enderror
          </div>
        </div>

        <div class="col-sm-12 pb-3">
          <label for="name">Name</label>
          <div class="input-group">
            <div class="input-group-prepend"></div>
            <input type="text" class="form-control" id="productnumber" name="name" value="{{ $prod['product_name'] }}" required autocomplete="name" autofocus>

            @error('name')
            <span class="invalid-feedback" role="alert">
              <strong>{{ $message }}</strong>
            </span>
            @enderror
          </div>
        </div>

        <!-- Description -->

        <div class="col-sm-12 pb-3">
          <label for="description">Description</label>
          <div class="input-group">
            <div class="input-group-prepend"></div>
            <input type="text" class="form-control" id="description" name="description" value="{{ $prod['product_description'] }}" required autocomplete="description" autofocus>

            @error('description')
            <span class="invalid-feedback" role="alert">
              <strong>{{ $message }}</strong>
            </span>
            @enderror
          </div>
        </div>


        <!-- Adresse -->

        <div class="col-sm-12 pb-3">
          <label for="imageURL">Image URL</label>
          <div class="input-group">
            <div class="input-group-prepend"></div>
            <input type="text" class="form-control" id="imageURL" name="imageURL" value="{{ $prod['product_image_url'] }}" autocomplete="imageURL" autofocus>

            @error('imageURL')
            <span class="invalid-feedback" role="alert">
              <strong>{{ $message }}</strong>
            </span>
            @enderror
          </div>
        </div>

        <input type="hidden" class="form-control" id="numbprobes" name="numbprobes" value="59"></input> 

        <div class="dropdown-divider"></div> 
        <p> <i class="fa fa-info-circle fa-2x" aria-hidden="true"></i> Please select Probes for product.</p>

        <div class="input-group mb-2 xs-4">
          <div class="input-group-prepend">
            <label class="input-group-text" for="probe1">Probe 1</label>
          </div>
          <select name="probe1" class="custom-select" id="probe1">
           @foreach($unittypes['result'] as $indexKey => $row)

             <option value="{{$row['unittype_id'] }}" @if($row['unittype_id']==0) selected="selected" @endif> {{ $row['unittype_description'] }} </option>
           @endforeach
         </select>
       </div>
    
  </br></br>

  <div class="form-group row mb-0">
    <div class="col-md-12 offset-md-4">
      <button type="submit" class="btn btn-primary">
        <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;{{ __('Oppdater') }}
      </button>

      <button id="cancel_dommer" onclick="window.location.href = '/products';" data-toggle="tooltip" title="cancel" type="button" class="btn btn-success" style="padding-button : 15px;"><i class="fa fa-ban" aria-hidden="true"></i>&nbsp;@lang('buttons.cancel')
      </button>

    </div>
  </div>
    @include('errors')
  </form>

@endforeach

</div>
<!-- Footer -->
@endsection

Please help....

0 likes
4 replies
esorone's avatar

Hello, I'm not sure, but you used "id="productnumber" more than once in the form. This may causes the issue.

Kr

ajithlal's avatar

Are you sure the database field productnumber does not have an underscore to separate two words like product_number ? because rest of the field names are different from this.

Please check {{ $prod['productnumber'] }} or {{ $prod['product_number'] }}

Snapey's avatar
Snapey
Best Answer
Level 122

Disabled fields are not sent in form requests. Thats just the way HTML works.

Please or to participate in this conversation.