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

Andreas94's avatar

Query for ajax added items

Hello everyone, I have elements in one page:

consul date

Each page is about a video game, so the number of consoles is variable, I in the blade have:

  @foreach($giochi->infogiochi as $info)
  <div id="stxrelease" class="form-group card col-12">
    <div class="card-body">
      <h3>Data di rilascio</h3>
      <div class="row">
        <div class="col-12">
            {{ Form::label('console', 'Console') }} <br />
          <select class="col-12 form-control select2" name="release" style="width:80%">
            @foreach($console as $value)
              @if($info->id_console == $value->id)
              <option value="{{ $value->id }}" selected>{{ $value->nome_cat }}</option>
              @else
              <option value="{{ $value->id }}">{{ $value->nome_cat }}</option>
              @endif
            @endforeach
          </select>
        </div>
        <div class="col-12">
            {{ Form::label('genere', 'Data di pubblicazione') }} <br />
          <input class="form-control datepicker" type="text" name="releasedata{{$info->id}}" value="{{$info->data}}">
        </div>
      </div>
      <div class="mt-2 col-12 text-right">
        <button data-target="#stxrelease_{{ $info->id }}" class="btn btn-danger remove_field" type="button" name="button">Elimina</button>
      </div>
    </div>
  </div>
  @endforeach

other items will be added via a <button data-node-template, of course I will not be able to enter $info->id not knowing the console that will be inserted and how many.

is it possible to make such a request?

foreach ($request->release as $value) {
    if($request->release) {
        $query = New RichiestaGioco();
        $query->id_utente =  \IPS\Member::loggedIn()->member_id;;
        $query->id_gioco = $giochi->id;
        $query->tipo = '1';
        $query->genere = '6';
        $query->dato  = '["id_console": '.$value->release.', "data": '.$value->releasedata.']';
        $query->status = '1';
        $query->save();
    }
}

basically I would like to save the changed data of all requests, only if changed...

My main problem is:

  • can I make a general request and repeat it for each item on the page?
  • how can I request an added element with data-node-template?

here an image to make you better understand how the page will be structured...

https://imgur.com/6OD524g

0 likes
3 replies
Andreas94's avatar

really guys, no help? I haven't solved it yet...

Andreas94's avatar

Still here for this issue... Really nobody has any idea how he can create new records with forms added in ajax?

Please or to participate in this conversation.