Jump to content

Proper way to get checkbox values


owzim
 Share

Recommended Posts

Hi,

I have a page field, called status.

In there are 3 pages with the names of let's say is_liquid, is_translucent, is_hot. Since it's checkboxes, "Multiple pages (PageArray)" has to be activated in field options/details.

So How to acces it?

Do Really have to look into the array to see if the option is there? That's cumbersome, even with in_array (since I would have to pass the actual page objects):

foreach ($page->status as $status) {
   $status->name;
}

I'd rather have something like:

if($page->status->is_hot) {
    // something
}

Please help! =)

Link to comment
Share on other sites

One thing I want to mention is that you don't want to actually have a field of your own called "status", just because that is already a built-in field for every page. That is on our reserved words list, so I don't think PW will let you create a field with that name, but just wanted to mention it. 

  • 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

×
×
  • Create New...