I am building a legacy widget where I need to access some checkbox values added to the DOM in runtime using client script. For example:
<input id="groups-2-523221" type="checkbox" value="523221" name="groups[]" />
<input id="groups-2-303393" type="checkbox" value="303393" name="groups[]" />
This is how it looks like:
In classic widget editor mode, I can grab the values successfully by iterating through the $_POST['groups']
array. However, $_POST['groups']
is inaccessible when placing the widget in the block widget editor.
I can understand that the reason is that form is not being "posted" physically. But I am unable to find a solution. What is the best way to accomplish this?
$_POST
, since that part of the process is handled by theWP_Widget
class. Also, your fieldname
is not unique, so multiple instances of the widget would interfere with each other. So it seems like you're doing something unusual here, and more context would be helpful.