Jump to content

Ouput formatting and getting selection options through the API


Recommended Posts

I've got this code:

$field = wire('fields')->get('mySelectOptionsField');
$options = $field->type->getOptions($field);

echo $options->first()->title;

The echoed statement is not HTML-encoded. However, when you get select titles from $page rather than from $fields the title is HTML-encoded.

I get that this is intended behaviour. I just wanted to check:

  1. When in the front-end and using the API is the general rule anything you get via $pages or $page has of set to true by default but anything else — such as my example above — there is no output formatting since that only applies in the context of pages
  2. Is there an in-built way to HTML-encoded from $options as above — or should I just used $sanitizer->entites()?


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

  • Recently Browsing   0 members

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