_pageHeaderTemplates[self::HEADER_LIST] = 'Manage "%tradeShowName%" Trade Show Attendees'; $this->_pageHeaderTemplates[self::HEADER_NEW] = 'Add new %itemName% to "%tradeShowName%" Trade Show'; return parent::_init(); } protected function _initAction() { $this->_initApplication(); return parent::_initAction(); } /** * /{tradeShowId} * /{tradeShowId}?action={action} */ protected function _initApplication() { $obj = $this->_getDataObj(); $params = $this->getRestParams(); $paramCount = count($params); $action = Qs_Request::getRequestValue('action'); if (in_array($action, $this->_actions)) { if (1 === $paramCount) { $obj->setTradeShowId($params[0]); $this->_messagePlaceholders['tradeShowName'] = $obj->getTradeShowData('title'); } else { $this->_do404(); } } else { $this->_do404(); } $this->_setBackUrl(VendorAttendeeAdminView::getPage('url') . '/' . $this->_getDataObj()->getTradeShowId()); return $this; } protected function _getNewForm(array $options = []) { $options = array_merge($this->_getAttendeeFormOptions(), $options); return parent::_getNewForm($options); } protected function _getEditForm(array $options = []) { $options = array_merge($this->_getAttendeeFormOptions(), $options); return parent::_getEditForm($options); } protected function _getAttendeeFormOptions() { $options = [ 'tradeShowObj' => $this->_getDataObj()->getTradeShowObj(), 'userAutocompleteUrl' => UserAutocompleteAdminView::getUserAutocompleteUrl4TradeShow(), ]; return $options; } protected function _initFromForm(\Qs_Form $form) { $data = $form->getValues(); if (!$data['attendeeId']) { $data['attendeeId'] = 0; } $data['_attendeeId'] = $form->getElement('attendeeId')->getTitle(); $data['tradeShowId'] = $this->_getDataObj()->getTradeShowId(); $data['recordType'] = Entity::TYPE_SINGLE_ATTENDEE; if ($data['action'] == 'insert') { $data['registrationDate'] = date('Y-m-d H:i:s'); } $data['bought'] = "y"; $this->_getDataObj()->initFromForm($data); return $this; } }