getMethod(); if (0 == strcasecmp($_SERVER['REQUEST_METHOD'], $method)) { $data = Qs_Request::get($method); $itemIdMatched = true; if (($itemId = $this->getCmsItemId())) { $itemIdMatched = (isset($data['__idItem']) && $data['__idItem'] == $itemId); } return ($itemIdMatched && 0 === strpos($data['action'], 'insert')); } return false; } protected function _initElements() { $defaults = (array) $this->_getDefaults(); if (count($defaults) > $this->getMaxAttendeeCount()) { $defaults = array_slice($defaults, 0, $this->getMaxAttendeeCount(), true); } // current attendee if ($this->getAllowCurrentUser() && NewForm::RENDER_MODE_FULL === $this->getRenderMode()) { $form = new AttendeeItemForm([ 'allowDelete' => $this->getAllowDelete(), 'allowNonMembers' => $this->getAllowNonMembers(), 'showStaticAttendeeType' => $this->getShowStaticAttendeeType(), 'deletedMemberAttendee' => $this->getDeletedMemberAttendee(), 'currentUserId' => $this->getCurrentUserId(), 'mode' => AttendeeItemForm::MODE_CURRENT_USER, 'index' => 'current', 'eventEntity' => $this->getEventEntity(), 'alaCarteItemsType' => $this->getAlaCarteItemsType(), 'workshopType' => $this->getWorkshopType(), 'defaults' => Qs_Array::get($this->_defaults, 'current', []), ]); $this->addSubForm($form, 'current'); $firstItem = reset($defaults); $itemMode = (isset($firstItem['mode'])) ? $firstItem['mode'] : AttendeeItemForm::MODE_CHOOSE_TYPE; if (NewForm::RENDER_MODE_FULL === $this->getRenderMode() && $firstItem && AttendeeItemForm::MODE_CURRENT_USER === $itemMode) { unset($defaults['current']); } } // additional attendees if ($this->getAllowNonMembers() || $this->getAllowMembers()) { $itemOptions = [ 'allowDelete' => $this->getAllowDelete(), 'allowMembers' => $this->getAllowMembers(), 'allowNonMembers' => $this->getAllowNonMembers(), 'showStaticAttendeeType' => $this->getShowStaticAttendeeType(), 'deletedMemberAttendee' => $this->getDeletedMemberAttendee(), 'userAutocompleteUrl' => $this->getUserAutocompleteUrl(), 'eventEntity' => $this->getEventEntity(), 'alaCarteItemsType' => $this->getAlaCarteItemsType(), 'workshopType' => $this->getWorkshopType(), ]; foreach ($defaults as $index => $data) { $itemOptions['defaults'] = (array) $data; $itemOptions['index'] = $index; $form = new AttendeeItemForm($itemOptions); $this->addSubForm($form, (string) $index); } } return $this; } public function loadDefaultDecorators() { if (false == $this->loadDefaultDecoratorsIsDisabled() && null == $this->getDecorators()) { if (NewForm::RENDER_MODE_ATTENDEE === $this->getRenderMode()) { $this->addDecorator('FormElements'); } else { $this->addDecorator('FormElements') ->addDecorator('DtDdWrapper'); } } return $this; } public function initRender() { parent::initRender(); if (($decorator = $this->getDecorator('HtmlTag'))) { $decorator->setOption('id', $this->getId()); } return $this; } public function setRenderMode($renderMode) { $this->_renderMode = $renderMode; return $this; } public function getRenderMode() { return $this->_renderMode; } public function setIndex($index) { $this->_index = (int) $index; return $this; } public function getIndex() { return $this->_index; } public function setMaxAttendeeCount($maxAttendeeCount) { $this->_maxAttendeeCount = $maxAttendeeCount; return $this; } public function getMaxAttendeeCount() { return $this->_maxAttendeeCount; } public function setAllowMembers($allowMembers) { $this->_allowMembers = $allowMembers; return $this; } public function getAllowMembers() { return $this->_allowMembers; } public function setAllowNonMembers($allowNonMembers) { $this->_allowNonMembers = $allowNonMembers; return $this; } public function getAllowNonMembers() { return $this->_allowNonMembers; } public function setShowStaticAttendeeType($showStaticAttendeeType) { $this->_showStaticAttendeeType = $showStaticAttendeeType; return $this; } public function getShowStaticAttendeeType() { return $this->_showStaticAttendeeType; } public function getDeletedMemberAttendee() { return $this->_deletedMemberAttendee; } public function setDeletedMemberAttendee($message) { $this->_deletedMemberAttendee = $message; return $this; } public function setCurrentUserId($currentUserId) { $this->_currentUserId = $currentUserId; return $this; } public function getCurrentUserId() { return $this->_currentUserId; } public function setAllowCurrentUser($allowCurrentUser) { $this->_allowCurrentUser = $allowCurrentUser; return $this; } public function getAllowCurrentUser() { return $this->_allowCurrentUser; } public function setUserAutocompleteUrl($userAutocompleteUrl) { $this->_userAutocompleteUrl = $userAutocompleteUrl; return $this; } public function getUserAutocompleteUrl() { return $this->_userAutocompleteUrl; } public function setAllowDelete($allowDelete) { $this->_allowDelete = $allowDelete; return $this; } public function getAllowDelete() { return $this->_allowDelete; } }