/**
  * Save group data to the database
  *
  * @return JSONResponse Returns status and errors if status is equal to failure
  */
 protected function save(EavFieldGroupCommon $specFieldGroup)
 {
     $this->createLanguageCodes();
     if (count($errors = $this->validate($this->request->getValueArray(array("name_{$this->languageCodes[0]}")), $this->languageCodes)) == 0) {
         foreach ($this->application->getLanguageArray(true) as $langCode) {
             $specFieldGroup->setValueByLang('name', $langCode, $this->request->get('name_' . $langCode));
         }
         $specFieldGroup->save();
         return new JSONResponse(array('id' => $specFieldGroup->getID()), 'success');
     } else {
         return new JSONResponse(array('errors' => $this->translateArray($errors)), 'failure', $this->translate('_could_not_save_specification_group'));
     }
 }
Example #2
0
 /**
  * Get specification group item instance
  *
  * @param int|array $recordID Record id
  * @param bool $loadRecordData If true loads record's structure and data
  * @param bool $loadReferencedRecords If true loads all referenced records
  * @return SpecFieldGroup
  */
 public static function getInstanceByID($recordID, $loadRecordData = false, $loadReferencedRecords = false)
 {
     return parent::getInstanceByID(__CLASS__, $recordID, $loadRecordData, $loadReferencedRecords);
 }