PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
/
forms
<?php class NewsTagForm extends CFormModel { public $news_id; public $tag_id; public $tag; public function rules() { return array( array('news_id,tag_id', 'required'), array('tag','length', 'max' => 255), ); } protected function preProcess() { if (isset($this->tag)) { $this->tag = trim($this->tag); if (strlen($this->tag)) { $this->tag = strtoupper($this->tag); $tag = Tag::model()->find('name=:name', array(':name' => $this->tag)); if (!isset($tag)) { $tt = new Tag(); $tt->name = $this->tag; $tt->save(); $this->tag_id = $tt->id; } else { $this->tag_id = $tag->id; } } } } public function save($item = null) { $this->preProcess(); $news = NewsTag::model()->find('news_id=:news_id and tag_id=:tag_id', array('news_id' => $this->news_id, 'tag_id' => $this->tag_id)); if (isset($news)) { return true; } $news = new NewsTag(); $news->news_id = $this->news_id; $news->tag_id = $this->tag_id; if ($news->save()) { return true; } else { $errors = $news->getErrors(); $mess = ''; foreach ($errors as $error) { foreach ($error as $err) { $mess .= $err.' dfdfd'; } } throw new Exception($mess); } } }
[+]
..
[-] ColorForm.php
[edit]
[-] ProfileResetPassForm.php
[edit]
[-] NewsCommentForm.php
[edit]
[-] SkinForm.php
[edit]
[-] PageForm.php
[edit]
[-] BLoginForm.php
[edit]
[-] UserResetPassForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] NewsForm.php
[edit]
[-] ContributorForm.php
[edit]
[-] News_CategoriesForm.php
[edit]
[-] InviteForm.php
[edit]
[-] NewsTagForm.php
[edit]
[-] DomainForm.php
[edit]