[wp-trac] [WordPress Trac] #10556: Ability to compare arrays in checked() function
WordPress Trac
wp-trac at lists.automattic.com
Sun Sep 27 15:21:52 UTC 2009
#10556: Ability to compare arrays in checked() function
-------------------------+--------------------------------------------------
Reporter: sudar | Owner: westi
Type: enhancement | Status: accepted
Priority: normal | Milestone: Unassigned
Component: Template | Version:
Severity: normal | Keywords: reporter-feedback
-------------------------+--------------------------------------------------
Changes (by sudar):
* cc: sudar@… (added)
Comment:
Here is a scenario which explains what I am try to do.
Let's say I am writing a Plugin, which is displaying all top level pages
(as checkboxes) and the user will be selecting some of them. I will have
the name of the checkboxes as an array (eg: selected_pages[]), so that I
can easily handle the post variables when the form is submitted.
Now the next time, when the page is displayed, I have to keep the
checkboxes that were already selected as checked. I will have the selected
pages as an array, and instead of looping through every time to find out
whether the current page is there in the array or not, I can pass the
current id and the array to the checked function which can print
checked='checked', if the current page id is present in the array.
I have attached a small Plugin to demonstrate this.
(sorry for the delay in reply, I didn't noticed the status change)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10556#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list