/** * Called via ajax by edit forms which have many-to-many widgets * * @param dmWebRequest $request */ public function executePaginateRelation(dmWebRequest $request) { $field = dmString::lcfirst($request->getParameter('field')); $startPage = $request->getParameter('page'); $maxPerPage = $request->getParameter('maxPerPage'); $this->getUser()->setAttribute($this->getModuleName() . '.' . $field . '.max_per_page', $maxPerPage, 'admin_module'); $search = $request->getParameter('search', false); $model = dmString::tableize($this->getDmModule()->getModel()); $this->{$model} = $this->getObject(); $this->nearRecords = array(); $this->form = $this->configuration->getForm($this->{$model}, array('widgets' => array($field))); $this->field = $this->form->getWidget($field); $this->search = $search; $query = $this->paginationCreateRelationQuery($field, $request->getParameter('pk'), $search); $pager = $this->field->getPager(); $pager->setQuery($query); $pager->setMaxPerPage($maxPerPage); $pager->setPage($startPage); $this->name = $field; $fields = array_diff(array_keys($this->form->getWidgetSchema()->getFields()), array($field)); foreach ($fields as $field) { unset($this->form[$field]); } $this->configuration->setFormDisplay(array($this->name)); $this->setTemplate('edit'); //$this->setLayout(false); }
protected function renderNewLink() { $link = $this->helper->link('@' . $this->foreignModule->getUnderscore() . '?action=new')->text($this->i18n->__('New'))->set('.s16.s16_add_little'); if ($this->relation instanceof Doctrine_Relation_ForeignKey) { $link->param('defaults[' . $this->relation->getForeign() . ']', $this->record->get('id')); } elseif ($this->relation instanceof Doctrine_Relation_Association) { $opposite = $this->relation['localTable']->getAssociationOppositeRelation($this->relation); if ($opposite) { $link->param('defaults[' . dmString::tableize($opposite->getAlias()) . '_list][]', $this->record->get('id')); } } return $link->render(); }
/** * Called via ajax by edit forms which have many-to-many widgets * * @param dmWebRequest $request */ public function executePaginateRelation(dmWebRequest $request) { $field = lcfirst($request->getParameter('field')); $relation = dmString::camelize(substr($field, 0, strlen($field) - 5)); //remove _list @todo make it given by $request, using .metadata() and writting it within template $table = $this->getDmModule()->getTable(); if ($table->hasRelation($relation)) { $relation = $table->getRelation($relation); } elseif ($table->hasRelation($field)) { $relation = $table->getRelation($field); } elseif ($table->hasRelation($relation = dmString::camelize($field))) { $relation = $table->getRelation($relation); } $startPage = $request->getParameter('page'); $maxPerPage = $request->getParameter('maxPerPage'); $this->getUser()->setAttribute($this->getModuleName() . '.' . $field . '.max_per_page', $maxPerPage, 'admin_module'); $search = $request->getParameter('search', false); $model = dmString::tableize($this->getDmModule()->getModel()); $this->{$model} = $this->getObject(); $this->nearRecords = array(); $this->form = $this->configuration->getForm($this->{$model}); $this->field = $this->form->getWidget($field); /** * @var dmDoctrinePager */ $pager = $this->field->getPager(); $pager->setMaxPerPage($maxPerPage); $pager->setPage($startPage); $query = $this->createPaginateRelationQuery($field, $relation, $search); $pager->setQuery($query); $this->name = $field; $fields = array_diff(array_keys($this->form->getWidgetSchema()->getFields()), array($field)); foreach ($fields as $field) { unset($this->form[$field]); } $this->configuration->setFormDisplay(array($this->name)); $this->setTemplate('edit'); $this->setLayout(false); }