public function addAction() { // Handle edit vocabulary form. $profileType = new UserProfilesType(); $this->_profileType = $profileType; $this->view->profileType = $profileType; if ($this->_getParam('submit')) { $profileType->label = $this->_getParam('name'); $profileType->description = $this->_getParam('description'); $profileType->public = $this->_getParam('public'); $profileType->required = $this->_getParam('required'); $elementSet = new ElementSet(); $elementSet->name = $profileType->label . " Elements"; $elementSet->description = "Elements for " . $profileType->label; $elementSet->record_type = 'UserProfilesType'; $elementSet->save(); $this->_elementSet = $elementSet; $profileType->element_set_id = $elementSet->id; $elementInfos = $this->_getElementInfos(); $profileType->setElementInfos($elementInfos); $multiInfos = $this->_getMultiElementInfos(); $profileType->setMultiElementInfos($multiInfos); if ($profileType->save(false)) { $this->_helper->flashMessenger(__('The profile type was successfully added.'), 'success'); $this->redirect('user-profiles'); } else { $elementSet->delete(); $errors = $profileType->getErrors(); $this->_helper->flashMessenger($errors, 'error'); } } }