public function init() { //get user lsit $userM = new Application_Model_User(); $usersArr = $userM->getUsersList(null, '--- Select Author ---'); $this->addElement('select', 'userId', array('label' => 'Author:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select author.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $usersArr)); $categories = new Application_Model_Category(); $categoriesArr = $categories->getCategory("--- Select Category ---", "advice"); $this->addElement('select', 'categoryId', array('label' => 'Category:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select advice category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr)); $this->addElement('text', 'title', array('label' => 'Title :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice title')))), 'decorators' => $this->elementDecorators)); $this->addElement('text', 'identifire', array('label' => 'URL Re-write :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice URL Re-write')))), 'decorators' => $this->elementDecorators)); // Add an body element $this->addElement('textarea', 'content', array('label' => 'Content:', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page content')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); // Add an body element $this->addElement('textarea', 'synopsis', array('label' => 'Synopsis:', 'required' => false, 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the synopsis')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('textarea', 'metaTitle', array('label' => 'Meta Title :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page identifire')))), 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'metaKeyword', array('label' => 'Meta Keyword :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'decorators' => $this->elementDecorators)); $this->addElement('textarea', 'metaDescription', array('label' => 'Meta Description :', 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'required' => false, 'decorators' => $this->elementDecorators)); $Name = new Zend_Form_Element_File('name'); $Name->setLabel('Upload an image:')->setRequired(false)->addValidator('Extension', false, 'jpg,png,gif')->clearDecorators()->addDecorators($this->fileDecorators); $this->addElements(array($Name)); $this->addElement('submit', 'savePublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Publish', 'label' => 'Save and Publish', 'decorators' => $this->buttonDecorators)); $this->addElement('submit', 'saveUnpublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Unpublish', 'label' => 'Save and Unpublish', 'decorators' => $this->buttonDecorators)); $this->addElement('submit', 'previewPage', array('required' => false, 'ignore' => true, 'title' => 'Preview Page', 'label' => 'Preview Page', 'decorators' => $this->buttonDecorators)); }
public function save(Application_Model_Category $category) { $data = array('account_id' => $category->getAccountId(), 'cate' => $category->getCategory()); if (null === ($id = $category->getId())) { $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('id = ?' => $id)); } }
public function init() { $this->addElement('text', 'title', array('label' => 'Title :', 'class' => '', 'decorators' => $this->elementDecorators)); $categories = new Application_Model_Category(); $categoriesArr = $categories->getCategory("--- Select Category ---", "advice"); $this->addElement('select', 'category_id', array('label' => 'Category:', 'style' => 'width: 250px;', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr)); $this->addElement('radio', 'status', array('label' => 'Staus: ', 'value' => '', 'multiOptions' => array('1' => "Published", '0' => "Unpublished", '' => "All"), 'decorators' => $this->elementDecorators)); $this->getElement('status')->setSeparator(''); $this->addElement('submit', 'submit', array('required' => false, 'ignore' => true, 'label' => 'Search', 'decorators' => $this->buttonDecorators)); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->addElementPrefixPath('Base_Validate', 'Base/Validate/', 'validate'); $arrWeight = array(); $arrWeight[0] = "--Select--"; for ($i = 1; $i <= 50; $i++) { $arrWeight[$i] = $i; } // Add an email element $this->addElement('text', 'title', array('label' => 'Enter title', 'required' => true, 'class' => "form", 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Post title can not be left blank.'))), array('Alphachar', true, array('messages' => array('alnumStringNotValid' => 'Please remove special characters.')))))); //default selected Status option as per permission settings $userNs = new Zend_Session_Namespace('members'); $userId = $userNs->userId; $where = "user_id='{$userId}' AND permission_id=4"; $user_permission = new Application_Model_UserPermission(); $user_permission = $user_permission->fetchRow($where); $savedUserPermission = $user_permission->getFriendGroupId(); $selectedPermission = "public"; if ($savedUserPermission == 4) { $selectedPermission = "private"; } $arrStatus = array("public" => "Public", "private" => "Just Me"); //get user permission and create new dropdwon, added by Mahipal Adhikari on 28-Mar-2011 $group = new Application_Model_FriendGroup(); $arrStatus = $group->getFriendGroup('--select--', null); $selectedPermission = $savedUserPermission; $this->addElement('select', 'status', array('label' => 'Permissions', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select journal post permission.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'value' => $selectedPermission, 'MultiOptions' => $arrStatus)); //$arrStatus=Array("Public"=>"Public(Default)", "friends"=>"Friends and Family","travel"=>"Travel Mates","family"=>"Friends Family And Mates"); $category = new Application_Model_Category(); $arrCategory = $category->getCategory("-- Select Category --", "blog"); $this->addElement('select', 'categoryId', array('label' => 'Choose post category', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrCategory)); $this->addElement('text', 'location', array('label' => 'Enter destination', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Destination can not be left blank.')))))); $this->addElement('textarea', 'tags', array('label' => 'Tag your post', 'required' => false, 'class' => 'blog_tag_textarea', 'rows' => '4', 'cols' => '40', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('textarea', 'content', array('label' => 'Edit your post', 'required' => true, 'rows' => '8', 'cols' => '80', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array("messages" => array('isEmpty' => 'Journal entry can not be left blank.')))))); $this->addElement('radio', 'comment', array('label' => 'Enable Comments ', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enable comment.')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => " ", 'decorators' => $this->elementDecorators, 'value' => 'yes')); $this->addElement('radio', 'publish', array('label' => 'Publish Settings', 'required' => true, 'multiOptions' => array('published' => "Publish Live", 'draft' => "Save for Later"), 'value' => 'published', 'separator' => " ", 'decorators' => $this->elementDecorators)); $this->addElement('select', 'weight', array('label' => 'Weight', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the status')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrWeight)); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Create Post', 'decorators' => $this->buttonDecorators)); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); // Add an email element $this->addElement('text', 'name', array('label' => 'Album Name', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the album name.')))))); $this->addElement('text', 'datepicker', array('label' => 'Album Date', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the album date.')))))); $this->addElement('hidden', 'date', array('label' => 'Date', 'filters' => array('StringTrim')))->clearDecorators(); $arrStatus = array("public" => "Public(Default)", "private" => "Private"); $this->addElement('select', 'status', array('label' => 'Album Status', 'class' => 'form', 'TABINDEX' => '6', 'class' => "form", 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the status')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrStatus)); $category = new Application_Model_Category(); $arrCategory = $category->getCategory("--Category--"); $this->addElement('select', 'categoryId', array('label' => 'Category', 'class' => 'form', 'TABINDEX' => '6', 'class' => "form", 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the category')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrCategory)); $this->addElement('text', 'location', array('label' => 'Location', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the location')))))); $this->addElement('textarea', 'description', array('label' => 'Description', 'required' => false, 'rows' => '4', 'cols' => '40', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('text', 'tags', array('label' => 'Tags', 'class' => "form", 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('radio', 'enableComments', array('label' => 'Enable Comments ', 'required' => true, 'TABINDEX' => '14', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'please enable comment')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => " ", 'decorators' => $this->elementDecorators, 'value' => 'yes')); $this->addElement('radio', 'enableLikes', array('label' => 'Enable Likes', 'required' => true, 'TABINDEX' => '14', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'please enable comment')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => " ", 'decorators' => $this->elementDecorators, 'value' => 'yes')); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Save', 'decorators' => $this->buttonDecorators)); }