/** * Get the model for the page subform. * This is on the group because a page object can be set embedded in another form. * * @param null $page * * @return null|PageModel */ public function getModel($page = null) { // Allow linked models. if (!$page) $page = new PageModel($this->get('baseurl')); // Because name can be changed. $name = $this->_attributes['name']; $els = $this->getElements(true, false); foreach ($els as $e) { /** @var $e FormElement */ if (!preg_match('/^[a-z_]*\[(.*?)\].*/', $e->get('name'), $matches)) continue; $key = $matches[1]; $val = $e->get('value'); // Meta attributes if(strpos($e->get('name'), $name . '_meta') === 0){ $val = $e->get('value'); $page->setMeta($key, $val); } elseif(strpos($e->get('name'), $name) === 0){ $page->set($key, $val); } else{ continue; } } return $page; // Add in any insertables too, if they're attached. // DISABLING 2012.05 cpowell /* if(($i = $this->getElementByName('insertables'))){ $els = $i->getElements(); foreach($els as $e){ if(!preg_match('#^insertable\[(.*?)\].*#', $e->get('name'), $matches)) continue; $submodel = $page->findLink('Insertable', array('name' => $matches[1])); $submodel->set('value', $e->get('value')); } } return $page; */ }