jan 17 Posted March 26, 2014 Hi there, I have a template with a field type page. Now I try to remove one of the pages inside this field. I think I'm kind of blind – it won't do what I want it do foreach ($myPage->pageField as $pageInField) { if( /* condition to find page to remove */ ) { $myPage->pageField->remove($pageInField); break; } } Thank you!!! Share this post Link to post Share on other sites
kongondo 7,394 Posted March 26, 2014 Something like this could probably work.... $x = $pages->get(1412);//necessarily verbose - could have done this in foreach foreach ($x->myPageField as $f) { if ($f->name == 'example') {//set your condition $x->of(false); $x->myPageField->remove($f); $x->save(); } } 2 Share this post Link to post Share on other sites
jan 17 Posted March 27, 2014 Thank you very much!! This is the solution. Share this post Link to post Share on other sites
bracketfire 18 Posted November 29, 2014 I have a PageField that holds a single page. I've been trying to find the proper way to unset it, I've seen an example of using "unset" but that doesn't feel right, or very processwire-ish. Right now, I'm using $facility->region_page = new NullPage(); But this also, just doesn't feel right but appears to work. Is there a best practice for unsetting a pagefield? Share this post Link to post Share on other sites
Macrura 3,094 Posted November 29, 2014 @bracketfire - this should work: $facility->region_page = ''; Share this post Link to post Share on other sites