Good day. Not strong in the intricacies, tell me how to pass the id in action, when I put the pens search works:

<form method="post" action="index.php?page=search&locationid=" id="base-search-hotels-form" autocomplete="off"> <input type="hidden" name="locationid" id="base-search-hotels-form-locationid" value="{if isset($currentLocation)}{$currentLocation[0]["id"]}{/if}"/> <input type="text" class="form-control" id="base-search-location" placeholder="Направление" value="{if isset($currentLocation)}{$currentLocation[0]["locationname"]}{/if}" /><br> <input type="text" class="form-control" name="roomscount" id="base-search-roomscount" value="" placeholder="Спальных мест" /> <label for="dateto" id="label-br">Дата заезда</label> <input type="date" class="form-control" id="dateto" name="dateto" /> <label for="datefrom" id="label-br">Дата выезда</label> <input type="date" class="form-control" id="datefrom" name="datefrom" /> </form> <button type="button" class="btn btn-primary btn-lg" id="base-searchbtn" value="{$currentLocation[0]["id"]}"> Найти </button> 
  • What id, in what action. - u_mulder
  • From this Input: <input type = "text" class = "form-control" id = "base-search-location" placeholder = "Direction" value = "{if isset ($ currentLocation)} {$ currentLocation [0] [ "locationname"]} {/ if} "/> In action =" index.php? page = search & locationid = put here the value that is selected from the form - Den

2 answers 2

Add the required input attribute name : for example like this:

 <input type="text" name="locationid" ...> 

And remove the action from the locationid and leave it like this:

 action="index.php?page=search" 

And the very first input which type="hidden" then delete.

  • The question is that when choosing a location should be from the Input Direction, the direction id should come and fall into action = "index.php? Page = search & locationid = * the value from the input * should come here" - Den
  • @Den, do you understand that the parameter string in action is generated from the form fields when sending? In action there should be only the path to the form processing file and that's it. - Klym
  • Now I understand, but the fact is that with action in which the locationid will be nested, the paginator will work and the selection from the base will work will agree with the result of the field. As far as I understand, this is impossible because of my dementia in logic. If I send GET then it sends the ID, the question is, in this case, can I only transfer the locationid and not all the parameters to the browser string? Thank you in advance for the answers) - Den
  • @Den, That's it, that the parameters passed to the action are GET parameters, and the parameters from the form input are POST, as indicated by the method attribute. In the form processing file, the locationid is read as $ _GET ['locationid']. You only need to change this record to $ _POST ['locationid'] and everything will work fine for you. - Klym
  • Thanks for answering the processing file, I’m checking there: if (isset ($ _ GET ["locationid"])) $ smarty-> assign ('currentLocation', bookingLocationsGet ($ _ GET ["locationid"])); if (isset ($ _ POST ["locationid"])) $ smarty-> assign ('currentLocation', bookingLocationsGet ($ _ POST ["locationid"])); Once done like this: <input type = "hidden" name = "locationid" id = "base-search-hotels-form-locationid" value = "{if isset ($ currentLocation)} {$ currentLocation [0] [ "id"]} {/ if} "/> Now the necessary array comes, but now I think how to put the value in the string of the browser - Den

Arrival date Departure date
  <button type="submit" class="btn btn-primary btn-lg" id="base-searchbtn" value="{$currentLocation[0]["id"]}"> Найти </button> 

So everything works correctly, only you need to revise the pagination, the problem is in it