froot Posted September 18, 2020 Share Posted September 18, 2020 how do I return all the options of an option field? I have an option field on the children pages and need to list them. The API-documentation says as follows… $items = $fieldtypeOptions->getOptions($field); but it doesn't work. Also unclear if $fieldtypeOptions is to be used as is or would that be replaced with my field? It's not apparent if you're not a pro, the API documentation lacks examples or explanations as usual. Link to comment Share on other sites More sharing options...
Robin S Posted September 18, 2020 Share Posted September 18, 2020 https://processwire.com/docs/fields/select-options-fieldtype/#manipulating-options-on-a-page-from-the-api Quote Getting all possible options This retrieves all possible options for the field, regardless of whether they are selected or not (there is no page involved here). $field = $fields->get('countries'); $all_options = $field->type->getOptions($field); 1 Link to comment Share on other sites More sharing options...
froot Posted September 19, 2020 Author Share Posted September 19, 2020 thanks! I wonder though why the ->type-> part is not in the API doc https://processwire.com/api/ref/fieldtype-options/get-options/ because without it, doesn't work 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