ngrmm Posted June 12, 2019 Share 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? Link to comment Share on other sites More sharing options...
dragan Posted June 12, 2019 Share 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 Link to comment Share on other sites More sharing options...
flydev Posted June 12, 2019 Share 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 Link to comment Share on other sites More sharing options...
ngrmm Posted June 12, 2019 Author Share 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()? Link to comment Share on other sites More sharing options...
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