ngrmm Posted June 12, 2019 Posted June 12, 2019 i want to output some of my pagefields as options in a html select tag i can do this this way: $search_options = $templates->get("catalog_item")->fields; but i'm not able to sort them: $search_options = $templates->get("catalog_item")->fields("sort=label"); array_multisort() ksort() doesn't work either. is sort limited to pagearrays?
dragan Posted June 12, 2019 Posted June 12, 2019 you could try something like: $search_options = $templates->get("project")->fields; $fieldNames = array(); foreach($search_options as $so) { $fieldNames[] = $so->name; } sort($fieldNames); afaik, $search_options is an object, not an array. 1
flydev Posted June 12, 2019 Posted June 12, 2019 1 hour ago, ngrmm said: is sort limited to pagearrays? You can use sort() on WireArray derived objects : $search_options = $templates->get("catalog_item")->fields->sort("label"); // or sort("-label") 1
ngrmm Posted June 12, 2019 Author Posted June 12, 2019 thx @dragan and @flydev ok i understand. this also means that i'm not able to remove items (fields) with ->remove()?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now