/** * @param \Mindy\Form\BaseForm|ModelForm $owner * @param array $attributes * @throws Exception * @return array */ public function beforeSetAttributes($owner, array $attributes) { $model = $owner->getModel(); $ownerModel = $owner->getParentForm()->getInstance(); if (!isset($ownerModel->metaConfig)) { throw new Exception("metaConfig doesn't exists in model: " . $model->className()); } $meta = $ownerModel->metaConfig; if (empty($attributes['is_custom'])) { $attributes = array_merge($attributes, ['title' => $ownerModel->{$meta['title']}, 'keywords' => MetaGenerator::generateKeywords($ownerModel->{$meta['keywords']}), 'description' => MetaGenerator::generateDescription($ownerModel->{$meta['description']})]); } return parent::beforeSetAttributes($owner, $attributes); }
public function init() { parent::init(); $onSite = Mindy::app()->getModule('Meta')->onSite; if (is_null($onSite) || $onSite === false) { $this->exclude[] = 'site'; } }
public function getFields() { $model = $this->getInstance(); $fields = parent::getFields(); $user = Mindy::app()->user; if ($user) { if (!$user->is_superuser) { unset($fields['is_global']); } if (!$user->is_superuser && $model && $model->is_auto == 1) { unset($fields['is_locked']); } } return $fields; }
public function init() { parent::init(); $this->setOwnerAttribute(); }
/** * @return string */ public function getCreateForm() { return ModelForm::className(); }