public function edit($id) { if (!($facilities = Facilities::findById($id))) { Flash::set('error', __('Facilities not found!')); redirect(get_url('facilities')); } // check if trying to save if (get_request_method() == 'POST') { return $this->_edit($id); } $facilitiesgalleries = FacilitiesImage::findByFacilitiesId($id); //$features = FeatureImage::findByFacilitiesId($id); $this->display('facilities/edit', array('action' => 'edit', 'csrf_token' => SecureToken::generateToken(BASE_URL . 'facilities/edit/' . $id), 'facilities' => $facilities, 'facilitiesgalleries' => $facilitiesgalleries, 'id' => $id, 'pages' => Record::findAllFrom('Page', 'parent_id=1 order by parent_id,position'))); }