WP_List_Table custom filter field
-
I’ve made an admin page inside a plugin with a table which extends
WP_List_Tableclass.
Also, I’ve override functionextra_tablenavin this way:public function extra_tablenav($which) { ?> <div class="alignleft actions daterangeactions"> <label for="daterange-actions-picker" class="screen-reader-text"><?=__('Filter', 'iw-stats')?></label> <input type="search" name="date" id="daterange-actions-picker"/> <?php submit_button(__('Apply', 'iw-stats'), 'action', 'dodate', false); ?> <?php submit_button(__('Export as CSV', 'iw-stats'), 'action', 'doexport', false); ?> </div> <?php }It looks just as expected, but unfortunately when I submitting a form I’m getting a blank result on my field value (‘date’) in $_REQUEST.
-
This topic was modified 8 years, 10 months ago by
iworb.
-
This topic was modified 8 years, 10 months ago by
-
tablenav output is outside of the page’s form element, so input fields are not recognized as form data. Parameters need to be passed as URL parameters of a new request, which of course are then available in $_REQUEST. I suppose you could output your own mini-form. Submitting this form using the GET method would end up creating URL parameters, so it’s essentially the same thing.
Are you seriours? So why bulk actions inside form element and mine fields which is neighbour of bulk select is not? In my generated html they’re inside form and jQuery’s method ‘serialize’ works as expected. If I changed my form method to “GET” instead of “POST” there’s variable ‘date’, but it’s blank even if there’s actual value. Actually GET’s URL and jQuery’s serialized form must be the same, but they are not.
Here’s an example of generated form. Like you can see in 6th line mine function ouput inside the form.
Well, I think I’ve got it. Because of same names of inputs it was overriden and last value was sent.
I’m glad you found the problem. Sorry for the misinformation. I got tablenav and views mixed up. Serves me right for relying on memory!
The topic ‘WP_List_Table custom filter field’ is closed to new replies.