How to send selected data from form to controller?

Hello,

How can I send the selected data from the form to the controller?

I have:

[{foreach from=$manufacturers item="manufacturer"}]
  <li onclick="manSelector.submit();manSelector();">
  <input type='hidden' name="editval[oxmanufacturers__oxtitle]" value="[{ $manufacturer }]">				
	[{$manufacturer}]
  </li>
[{/foreach}]

With

$aParams = oxRegistry::getConfig()->getRequestParameter("editval");

I am getting all the manufacturers and not the selected one.

Thank you,
Martina

This must be so, because each hidden field in the foreach has a value and not just the selection. The hidden field usually has nothing to look for in the foreach. Here only the selection from the list is re-written.

Dear Martina,

I was looking for a solution on a problem when I found this post and I think that you would be able to help me. I am still new to oxid and I am having a hard time finding my way around it.

I am trying to connect a submit button of a form to a function in a controller.

As I examine your code, I think that the following part is what I am looking for:

  • Could you please explain to me what are manSelector.submit() and manSelector() in your code, and where are they located in your project? Is manSelector a controller class that contains a method submit? Am I even close? Or are these methods maybe located in the same file as your form?

    I would appreciate it a lot if you could give me a hint.

    Thank you very much!
    Ane

  • Those are just basic Javascript selector and function, nothing oxid specific.
    Have a look at literally any form in shop. You will find a set of hidden fields, there will be at least “fnc”, which tells the controller what to do, and there might be additional fields for all data this function needs.

    2 Likes

    Thank you very much!