Jump to content

return options of options field


froot
 Share

Recommended Posts

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

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);

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...