_galleryId = $galleryId; return $this; } public function getGalleryId() { if (!$this->_galleryId) { throw new Exception('Gallery ID is empty'); } return $this->_galleryId; } protected function _initElements() { $imageCfg = $this->getConfig('image'); $descriptionLength = (int) $this->getConfig('descriptionLength'); $this->addElement('static', 'albumTitle', ['label' => 'Album']); $this->addElement('text', 'title', ['label' => 'Title', 'required' => true, 'maxlength' => 255]); $this->addElement('pageAlias', 'alias', [ 'label' => 'Alias', 'required' => true, 'maxlength' => 200, 'sourceField' => 'title', 'aliasValidatorOptions' => [ 'table' => new Qs_Db_Table('GalleryImage'), 'column' => 'alias', 'currentId' => $this->_getData('id'), 'options' => ['where' => Qs_Db::getInstance()->quoteInto('`galleryId` = ?', 8, Qs_Db::INT_TYPE)] ], ]); $resize = $imageCfg->width . 'x' . $imageCfg->height . Qs_ImageFs::getResizeMethodAlias($imageCfg->method); $this->addElement('extendedImage', 'image', ['label' => 'Image', 'required' => true, 'resize' => $resize]); $this->addElement( 'textarea', 'description', [ 'label' => 'Description', 'description' => 'Text space is limited to ' . $descriptionLength . ' characters.', ] ); $this->getElement('description')->addValidator( 'StringLength', true, ['max' => $descriptionLength, 'elementLabel' => $this->getElement('description')->getLabel()] ); $this->addElement('checkbox', 'enabled', ['label' => 'Show on user end', 'decoration' => 'simple']); return $this; } }