Exemple #1
1
 /**
  * Hook for node form - if type is Filemanager Node, add extra fields
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeForm(Zend_Form &$form, &$arguments)
 {
     $item =& array_shift($arguments);
     if (!Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest() && $item->type == "filemanager_file") {
         // Add Filemanager fields
         $form->setAttrib('enctype', 'multipart/form-data');
         $file = new Zend_Form_Element_File('filemanager_file');
         $file->setLabel("Select file")->setDestination(ZfApplication::$_data_path . DIRECTORY_SEPARATOR . "files")->setRequired(false);
         $form->addElement($file);
         $fields[] = 'filemanager_file';
         if ($item->id > 0) {
             // Fetch Filemanager object
             $factory = new Filemanager_File_Factory();
             $file_item = $factory->find($item->id)->current();
             if ($file_item) {
                 $existing = new Zend_Form_Element_Image('filemanager_image');
                 if (substr($file_item->mimetype, 0, 5) == "image") {
                     $imageid = $file_item->nid;
                 } else {
                     $imageid = 0;
                 }
                 $urlOptions = array('module' => 'filemanager', 'controller' => 'file', 'action' => 'show', 'id' => $imageid);
                 $existing->setImage(Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, 'default'));
                 $fields[] = 'filemanager_image';
             }
         }
         $options = array('legend' => Zoo::_("File upload"));
         $form->addDisplayGroup($fields, 'filemanager_fileupload', $options);
     } else {
         // Add content node image selector
     }
 }
Exemple #2
0
 public function getAddContentForm($submitLabel, $contentTitle = null, $contentDescription = null)
 {
     $database = Zend_Db_Table::getDefaultAdapter();
     $content = $database->select()->from('content')->order('content_id DESC')->query()->fetch();
     $imageName = $content['content_id'] + 1;
     $form = new Zend_Form();
     $form->setMethod('post');
     if ($submitLabel == 'Add Content!') {
         $form->setAttrib('enctype', 'multipart/form-data');
         $image = new Zend_Form_Element_File('foo');
         $image->setLabel('Upload an image:')->setDestination('../images');
         $image->addFilter('Rename', array('target' => $imageName . '.jpg', 'overwrite' => TRUE));
         $image->addValidator('Count', false, 1);
         $image->addValidator('Extension', false, 'jpg,png,gif');
         $form->addElement($image, 'foo');
     }
     $title = $form->createElement('text', 'title');
     $title->setRequired(true);
     $title->setValue($contentTitle);
     $title->setLabel('Title');
     $form->addElement($title);
     $description = $form->createElement('textarea', 'description', array('rows' => 10));
     $description->setRequired(true);
     $description->setValue($contentDescription);
     $description->setLabel('Description');
     $form->addElement($description);
     $form->addElement('submit', 'submit', array('label' => $submitLabel));
     return $form;
 }
 /**
  * Gets the form for adding and editing a document
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     $config = Zend_Registry::get('config');
     $form = new Zend_Form();
     $form->setAttrib('id', 'documentForm')->setAttrib('enctype', 'multipart/form-data')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $file = $form->createElement('file', 'document', array('label' => 'Upload File:'));
     $file->setRequired(true)->addValidator('Count', false, 1)->addValidator('Size', false, 10240000)->addValidator('Extension', false, $config->user->fileUploadAllowableExtensions->val ? $config->user->fileUploadAllowableExtensions->val : "");
     if (!isset($values['workshopDocumentId'])) {
         $form->addElement($file);
     }
     $title = $form->createElement('text', 'description', array('label' => 'File Description:'));
     $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['description']) ? $values['description'] : '');
     $form->addElement($title);
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     $file->setDecorators(array('File', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))));
     if (isset($values['workshopDocumentId'])) {
         $workshopDocumentId = $form->createElement('hidden', 'workshopDocumentId');
         $workshopDocumentId->setValue($values['workshopDocumentId']);
         $workshopDocumentId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($workshopDocumentId);
     }
     return $form;
 }
Exemple #4
0
 function form()
 {
     if (!isset($this->form)) {
         $form = new Zend_Form();
         $form->setAction($this->url());
         $form->setMethod('post');
         // Create and configure username element:
         $username = $form->createElement('text', 'username');
         $username->setLabel("Username");
         $username->addValidator('alnum');
         $username->addValidator('regex', false, array('/^[a-z]+/'));
         $username->addValidator('stringLength', false, array(6, 20));
         $username->setRequired(true);
         $username->addFilter('StringToLower');
         // Create and configure password element:
         $password = $form->createElement('password', 'password');
         $password->setLabel("Password");
         $password->addValidator('StringLength', false, array(6));
         $password->setRequired(true);
         // Add elements to form:
         $form->addElement($username);
         $form->addElement($password);
         // use addElement() as a factory to create 'Login' button:
         $form->addElement('submit', 'login', array('label' => 'Login'));
         // Since we're using this outside ZF, we need to supply a default view:
         $form->setView(new Zend_View());
         $this->form = $form;
     }
     return $this->form;
 }
 /** Create assetstore form */
 public function createAssetstoreForm()
 {
     $form = new Zend_Form();
     $action = $this->webroot . '/assetstore/add';
     $form->setAction($action);
     $form->setName('assetstoreForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'assetstoreForm');
     // Name of the assetstore
     $inputDirectory = new Zend_Form_Element_Text('name', array('label' => $this->t('Give a name'), 'id' => 'assetstorename'));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Input directory
     $basedirectory = new Zend_Form_Element_Text('basedirectory', array('label' => $this->t('Pick a base directory'), 'id' => 'assetstoreinputdirectory'));
     $basedirectory->setRequired(true);
     $form->addElement($basedirectory);
     // Assetstore type
     $assetstoretypes = array('0' => $this->t('Managed by MIDAS'), '1' => $this->t('Remotely linked'));
     // Amazon support is not yet implemented, don't present it as an option
     //                          '2' => $this->t('Amazon S3'));
     $assetstoretype = new Zend_Form_Element_Select('assetstoretype', array('id' => 'assetstoretype'));
     $assetstoretype->setLabel('Select a type')->setMultiOptions($assetstoretypes);
     // Add a loading image
     $assetstoretype->setDescription('<div class="assetstoreLoading" style="display:none"><img src="' . $this->webroot . '/core/public/images/icons/loading.gif"/></div>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $form->addElement($assetstoretype);
     // Submit
     $addassetstore = new Zend_Form_Element_Submit('addassetstore', $this->t('Add this assetstore'));
     $form->addElement($addassetstore);
     return $form;
 }
 public function createForm()
 {
     $form = new Zend_Form();
     $form->addElement('text', 'ip', array('label' => getGS('Start IP'), 'required' => true, 'validators' => array(array('notEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => getGS("Value is required and can't be empty")))), array('ip', true, array('messages' => array(Zend_Validate_Ip::NOT_IP_ADDRESS => getGS("'%value%' is not a valid IP Address")))))));
     $form->addElement('text', 'number', array('label' => getGS('Number of addresses'), 'required' => true, 'validators' => array(array('notEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => getGS("Value is required and can't be empty")))), array('greaterThan', true, array(0, 'messages' => array(Zend_Validate_GreaterThan::NOT_GREATER => getGS("'%value%' must be greater than '%min%'")))))));
     $form->addElement('submit', 'submit', array('label' => getGS('Save')));
     return $form;
 }
Exemple #7
0
 /**
  * Get priority form
  *
  * @return \Zend_Form
  */
 private function getForm()
 {
     $form = new Zend_Form();
     $resourceTypes = $this->auditService->getResourceTypes();
     $actionTypes = $this->auditService->getActionTypes();
     $form->addElement('select', 'resource_type', array('multioptions' => array('' => getGS('All')) + $resourceTypes, 'label' => getGS('Resource Type:'), 'onChange' => 'this.form.submit();'));
     $form->addElement('select', 'action_type', array('multioptions' => array('' => getGS('All')) + $actionTypes, 'label' => getGS('Action Type:'), 'onChange' => 'this.form.submit();'));
     return $form;
 }
Exemple #8
0
 /**
  * Add elements to a form for adding a link to a content node
  *
  * @param Zend_Form $form
  * @param string $label translated text
  * @param string $type link type
  */
 function addLinkFormElement(Zend_Form $form, $label, $type = "link")
 {
     // Build form element for linking, complete with AJAX code for lookup
     $element = new Zend_Form_Element_Text('connector_link_' . $type . '_txt');
     $element->setLabel($label);
     $hidden = new Zend_Form_Element_Hidden('connector_link_' . $type);
     $form->addElement($element, 'connector_link_' . $type . '_txt');
     $form->addElement($hidden, 'connector_link_' . $type);
 }
Exemple #9
0
 function indexAction()
 {
     $this->setupCache('default');
     $this->level = 500;
     $this->requirePriviledges();
     $this->toTpl('theInclude', 'profile');
     $data = $this->_request->getParams();
     $this->toTpl('module_title', $this->t('Profile of') . " " . $data['profile']);
     //check if the user is trying to view his profile
     $edit = false;
     if ($data['profile'] == 'me' || !$data['profile'] || $data['profile'] == 'index') {
         $profile = $_SESSION['user']['username'];
         $edit = true;
     } else {
         $profile = $data['profile'];
         $edit = false;
     }
     //try to get the user...
     $user = $this->getUserByName($profile);
     //now we need to get the data for this user
     $user['data'] = $this->getUserData($user['id']);
     //now if the user is viewing his profile, we need to create a nice form in order for him to edit the data
     if ($edit) {
         //get the fields
         $fields = $this->getUserProfileFields();
         $form = new Zend_Form();
         $form->setView($this->tpl);
         $form->setAttrib('class', 'form');
         $form->removeDecorator('dl');
         $form->setAction($this->config->host->folder . '/profiles/update')->setMethod('post');
         foreach ($fields as $k => $v) {
             switch ($v['field_type']) {
                 case "selectbox":
                     $values = explode(",", $v['default_value']);
                     break;
                 default:
                     $values = $v['default_value'];
                     break;
             }
             $form->addElement($this->getFormElement(array('name' => $v['name'], 'value' => $v['field_type'], 'title' => $this->t(ucfirst($v['name'])), 'use_pool' => 'valuesAsKeys', 'pool_type' => $values, 'novalue' => true), $user['data'][$v['name']]));
         }
         $form->addElement($this->getFormElement(array('name' => 'uid', 'value' => 'hidden'), $user['id']));
         $submit = new Zend_Form_Element_Submit('save');
         $submit->setLabel($this->t("Update"));
         $submit->setAttrib('class', "btn btn-primary");
         $form->addElement($submit);
         $form = $this->doQoolHook('pre_assign_user_profile_form', $form);
         $this->toTpl('formTitle', $this->t("Update your profile"));
         $this->toTpl('theForm', $form);
         $user = $this->doQoolHook('pre_assign_profiles_own_user_data', $user);
     } else {
         $user = $this->doQoolHook('pre_assign_profiles_user_data', $user);
     }
     $this->doQoolHook('pre_load_profiles_tpl');
     $this->toTpl('user', $user);
 }
 /**
  * Get priority form
  *
  * @return \Zend_Form
  */
 private function getForm()
 {
     $form = new Zend_Form();
     $translator = \Zend_Registry::get('container')->getService('translator');
     $resourceTypes = $this->auditService->getResourceTypes();
     $actionTypes = $this->auditService->getActionTypes();
     $form->addElement('select', 'resource_type', array('multioptions' => array('' => $translator->trans('All')) + $resourceTypes, 'label' => $translator->trans('Resource Type:', array(), 'logs'), 'onChange' => 'this.form.submit();'));
     $form->addElement('select', 'action_type', array('multioptions' => array('' => $translator->trans('All')) + $actionTypes, 'label' => $translator->trans('Action Type:', array(), 'logs'), 'onChange' => 'this.form.submit();'));
     return $form;
 }
Exemple #11
0
 protected function _getForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->view->baseUrl('/contact'));
     $form->addElement(new Zend_Form_Element_Text('name', array('label' => 'Name', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Text('email', array('label' => 'E-mail', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Textarea('body', array('label' => 'Question / feedback', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Submit('submit', array('label' => 'Send')));
     return $form;
 }
 /**
  * Add the elements to the form
  *
  * @param \Zend_Form $form
  */
 protected function addFormElements(\Zend_Form $form)
 {
     if ($this->user->hasEmailAddress()) {
         $createElement = new \MUtil_Form_Element_FakeSubmit('create_account');
         $createElement->setLabel($this->_('Create account mail'))->setAttrib('class', 'button')->setOrder(0);
         $form->addElement($createElement);
         $resetElement = new \MUtil_Form_Element_FakeSubmit('reset_password');
         $resetElement->setLabel($this->_('Reset password mail'))->setAttrib('class', 'button')->setOrder(1);
         $form->addElement($resetElement);
     }
     parent::addFormElements($form);
 }
 function staffSelector($allOption = true, $serviceId = null)
 {
     $staff = $this->listStaff($serviceId);
     $form = new \Zend_Form();
     $form->setMethod("GET");
     if ($allOption) {
         $form->addElement('select', 'staff', array('label' => 'Staff', 'multiOptions' => array('All' => 'All') + $staff, 'value' => $this->params()->fromQuery('staff') == 'All' ? null : $this->params()->fromQuery('staff')));
     } else {
         $form->addElement('select', 'staff', array('label' => 'Staff', 'multiOptions' => $staff, 'value' => $this->params()->fromQuery('staff')));
     }
     $form->addElement('submit', 'submitbutton', array('label' => 'Go', 'class' => 'btn'));
     return $form;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod(Zend_Form::METHOD_POST);
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml'))));
     $items = $this->getGuideYears();
     $e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items)));
     $form->addElement($e);
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити'));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
Exemple #15
0
 /** Main form */
 public function createMigrateForm($assetstores)
 {
     // Setup the form
     $form = new Zend_Form();
     $form->setAction('migratemidas2');
     $form->setName('migrateForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'migrateForm');
     // Input directory
     $midas2_hostname = new Zend_Form_Element_Text('midas2_hostname', array('label' => $this->t('MIDAS2 Hostname'), 'size' => 60, 'value' => 'localhost'));
     $midas2_hostname->setRequired(true);
     $form->addElement($midas2_hostname);
     $midas2_port = new Zend_Form_Element_Text('midas2_port', array('label' => $this->t('MIDAS2 Port'), 'size' => 4, 'value' => '5432'));
     $midas2_port->setRequired(true);
     $midas2_port->setValidators(array(new Zend_Validate_Digits()));
     $form->addElement($midas2_port);
     $midas2_user = new Zend_Form_Element_Text('midas2_user', array('label' => $this->t('MIDAS2 User'), 'size' => 60, 'value' => 'midas'));
     $midas2_user->setRequired(true);
     $form->addElement($midas2_user);
     $midas2_password = new Zend_Form_Element_Password('midas2_password', array('label' => $this->t('MIDAS2 Password'), 'size' => 60, 'value' => 'midas'));
     $midas2_password->setRequired(true);
     $form->addElement($midas2_password);
     $midas2_database = new Zend_Form_Element_Text('midas2_database', array('label' => $this->t('MIDAS2 Database'), ' size' => 60, 'value' => 'midas'));
     $midas2_database->setRequired(true);
     $form->addElement($midas2_database);
     $midas2_assetstore = new Zend_Form_Element_Text('midas2_assetstore', array('label' => $this->t('MIDAS2 Assetstore Path'), 'size' => 60, 'value' => 'C:/xampp/midas/assetstore'));
     $midas2_assetstore->setRequired(true);
     $form->addElement($midas2_assetstore);
     // Button to select the directory on the server
     $midas2_assetstore_button = new Zend_Form_Element_Button('midas2_assetstore_button', $this->t('Choose'));
     $midas2_assetstore_button->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
     $form->addElement($midas2_assetstore_button);
     // Assetstore
     $assetstoredisplay = array();
     $assetstoredisplay[0] = $this->t('Choose one...');
     // Initialize with the first type (MIDAS)
     foreach ($assetstores as $assetstore) {
         if ($assetstore->getType() == 0) {
             $assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
         }
     }
     $assetstore = new Zend_Form_Element_Select('assetstore');
     $assetstore->setLabel($this->t('MIDAS3 Assetstore'));
     $assetstore->setMultiOptions($assetstoredisplay);
     $assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $assetstore->setRequired(true);
     $assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
     $assetstore->setRegisterInArrayValidator(false);
     // This array is dynamic so we disable the validator
     $form->addElement($assetstore);
     // Submit
     $submit = new Zend_Form_Element_Button('migratesubmit', $this->t('Migrate'));
     $form->addElement($submit);
     return $form;
 }
 public function getForm()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml'))));
     $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC');
     $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_REPORTPLANKIND');
     $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUFORM', false);
     $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_EDUBASIS', false);
     $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     $items = $this->getGuideItems('T_COUNTRYTYPE', true);
     $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px'));
     $form->addElement($e);
     if (@(!$this->params['establishment'])) {
         $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші'));
         $form->addElement($e);
     }
     $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show'));
     $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'"));
     $form->addElement($e);
     $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5));
     $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'"));
     $form->addElement($e);
     $form->setElementDecorators(array('ViewHelper', 'Errors'));
     return $form;
 }
 public function indexAction()
 {
     /*
      *
      *	@todo email site admin when inserted
      *
      */
     $this->_model = new Joobsbox_Model_Jobs();
     // <createForm>
     $form = new Zend_Form();
     $form->setAction($_SERVER['REQUEST_URI'])->setMethod('post')->setAttrib("id", "formPublish");
     $title = $form->createElement('text', 'title')->setLabel('Job title:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Ex: "Flash Designer" or "ASP.NET Programmer"')->setRequired(true);
     $company = $form->createElement('text', 'company')->setLabel('Company:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true);
     $location = $form->createElement('text', 'location')->setLabel('Location:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Example: "London, Paris, Berlin, New York"')->setRequired(true);
     $categories[0] = $this->view->translate("Choose...");
     foreach ($this->_model->fetchCategories()->getIndexNamePairs() as $key => $value) {
         $categories[$key] = $value;
     }
     $greaterThan = new Zend_Validate_GreaterThan(false, array('0'));
     $greaterThan->setMessage($this->view->translate("Choosing a category is mandatory."));
     $category = $form->createElement('select', 'category')->setLabel('Category:')->addValidator('notEmpty')->addValidator($greaterThan)->setRequired(true)->setMultiOptions($categories);
     $description = $form->createElement('textarea', 'description')->setLabel('Job description:')->setDescription('HTML code is not accepted. Length must be less than 4000 characters.')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true);
     $application = $form->createElement('text', 'application')->setLabel('Means of application:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Ex: "Send CV to email ..." or "Apply online at URL ..."')->setRequired(true);
     $submit = $form->createElement('submit', 'submit')->setLabel("Add");
     $form->addElement($title)->addElement($company)->addElement($location)->addElement($category)->addElement($description)->addElement($application);
     $publishNamespace = new Zend_Session_Namespace('PublishJob');
     if (isset($publishNamespace->editJobId)) {
         $jobData = $this->_model->fetchJobById($publishNamespace->editJobId);
         $title->setValue($jobData['title']);
         $company->setValue($jobData['company']);
         $location->setValue($jobData['location']);
         $category->setValue($jobData['categoryid']);
         $description->setValue($jobData['description']);
         $application->setValue($jobData['toapply']);
         $exp = $form->createElement('text', 'expirationdate')->setLabel('Expiration date:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true)->setValue(date("m/d/Y", $jobData['expirationdate']));
         $form->addElement($exp);
         $submit->setLabel('Modify');
     }
     $form->addElement($submit);
     $this->form = $form;
     // </createForm>
     // Render the form
     $this->view->form = $form->render;
     if ($this->getRequest()->isPost()) {
         $this->validateForm();
         return;
     }
     $this->view->form = $this->form->render();
 }
 public function testRenderWithHidden()
 {
     $form = new Zend_Form();
     $form->setName('Test');
     $form->addElement('submit', 'Remove');
     $element = $form->createElement('hidden', 'Id');
     $element->setValue(10);
     $form->addElement($element);
     $decorator = new Application_Form_Decorator_RemoveButton();
     $decorator->setElement($form);
     $decorator->setSecondElement($element);
     $output = $decorator->render('content');
     // Output wird an content dran gehängt
     $this->assertEquals('content' . '<input type="hidden" name="Id" id="Id" value="10" />' . '<input type="submit" name="Remove" id="Remove" value="Remove" />', $output);
 }
Exemple #19
0
 function indexAction()
 {
     $form = new Zend_Form();
     $form->setAction($_SERVER['REQUEST_URI'])->setMethod('post')->setAttrib("id", "formPublish");
     $jobs_per_categ = $form->createElement('text', 'jobs_per_categ')->setLabel('Job title:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->addValidator('notEmpty')->setDescription('Ex: "Flash Designer" or "ASP.NET Programmer"')->setRequired(true);
     $submit = $form->createElement('submit', 'submit')->setLabel("Set");
     $config = Zend_Registry::get("conf");
     foreach ($this->textItems as $category => $items) {
         foreach ($items as $key => $label) {
             $item = $form->createElement('text', $key)->setLabel($label)->addValidator('notEmpty')->setRequired(true)->setValue($config->{$category}->{$key});
             $form->addElement($item);
         }
         $form->addDisplayGroup(array_keys($items), $category, array('legend' => ucfirst($category)));
     }
     foreach ($this->checkItems as $category => $items) {
         foreach ($items as $key => $label) {
             $item = $form->createElement('checkbox', $key)->setLabel($label)->setChecked($config->{$category}->{$key});
         }
         $form->getDisplayGroup($category)->addElement($item);
     }
     // Locale select
     $locales = Zend_Registry::get("Zend_Locale")->getTranslationList('language', 'en');
     foreach ($locales as $key => $value) {
         if (!file_exists("Joobsbox/Languages/{$key}")) {
             unset($locales[$key]);
         }
     }
     $locale = $form->createElement('select', 'locale')->setMultiOptions($locales)->setLabel($this->view->translate("Language"))->setValue($config->general->locale);
     $form->getDisplayGroup('general')->addElement($locale);
     // Timezone select
     $tzfile = file("config/timezones.ini.php");
     $timezones = array();
     foreach ($tzfile as $value) {
         $value = trim($value);
         $value = str_replace('"', '', $value);
         $timezones[$value] = $value;
     }
     $timezone = $form->createElement('select', 'site_timezone')->setMultiOptions($timezones)->setLabel($this->view->translate("Timezone"))->setValue($config->general->timezone);
     $form->getDisplayGroup('general')->addElement($timezone);
     $form->addElement($submit);
     $this->form = $form;
     $this->view->form = $form->render();
     if ($this->getRequest()->isPost()) {
         $this->validateForm();
         return;
     }
     $this->view->form = $this->form->render();
 }
 private function getFormLogin()
 {
     $form = new Zend_Form(array('disableLoadDefaultDecorators' => true));
     $email = new Zend_Form_Element_Text('login', array('disableLoadDefaultDecorators' => true));
     $email->addDecorator('ViewHelper');
     $email->addDecorator('Errors');
     $email->setRequired(true);
     $email->setAttrib('class', 'form-control');
     $email->setAttrib('placeholder', 'Login');
     $email->setAttrib('required', 'required');
     $email->setAttrib('autofocus', 'autofocus');
     $password = new Zend_Form_Element_Password('password', array('disableLoadDefaultDecorators' => true));
     $password->addDecorator('ViewHelper');
     $password->addDecorator('Errors');
     $password->setRequired(true);
     $password->setAttrib('class', 'form-control');
     $password->setAttrib('placeholder', 'Hasło');
     $password->setAttrib('required', 'required');
     $password->setAttrib('autofocus', 'autofocus');
     $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true));
     $submit->setAttrib('class', 'btn btn-lg btn-primary btn-block');
     $submit->setOptions(array('label' => 'Zaloguj'));
     $submit->addDecorator('ViewHelper')->addDecorator('Errors');
     $form->addElement($email)->addElement($password)->addElement($submit);
     return $form;
 }
Exemple #21
0
    /**
     * @group ZF-9364
     */
    public function testElementTranslatorPreferredOverDefaultTranslator()
    {
        $defaultTranslations = array(
            'isEmpty' => 'Default message',
        );
        $formTranslations = array(
            'isEmpty' => 'Form message',
        );        
        $elementTranslations = array(
            'isEmpty' => 'Element message',
        );
        $defaultTranslate = new Translator('ArrayAdapter', $defaultTranslations);
        $formTranslate = new Translator('ArrayAdapter', $formTranslations);
        $elementTranslate = new Translator('ArrayAdapter', $elementTranslations);
        
        Registry::set('Zend_Translator', $defaultTranslate);
        $this->form->setTranslator($formTranslate);        
        $this->form->addElement('text', 'foo', array('required'=>true, 'translator'=>$elementTranslate));
        $this->form->addElement('text', 'bar', array('required'=>true));

        $this->assertFalse($this->form->isValid(array('foo'=>'', 'bar'=>'')));
        $messages = $this->form->getMessages();
        $this->assertEquals(2, count($messages));
        $this->assertEquals('Element message', $messages['foo']['isEmpty']);
        $this->assertEquals('Form message', $messages['bar']['isEmpty']);
        
        $this->assertFalse($this->form->isValidPartial(array('foo'=>'', 'bar'=>'')));
        $messages = $this->form->getMessages();
        $this->assertEquals(2, count($messages));
        $this->assertEquals('Element message', $messages['foo']['isEmpty']);
        $this->assertEquals('Form message', $messages['bar']['isEmpty']);
    }
Exemple #22
0
 /**
  * Adds an element BusUnitId.<br/><br/>
  * Defaults:<br/>
  * name         = busunit_id<br/>
  * requires     = true<br/>
  * label        = Business unit<br/>
  * placeholder  = 'Choose a business unit'<br/>
  * dimension    = 6<br/>
  * modelfield   = busunit_id<br/>
  * firstvaluenull  = true
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  */
 public function addElementBusunitId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'busunit_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'busunit_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Business unit', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose a business unit', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $firstvaluenull = isset($options['firstvaluenull']) ? $options['firstvaluenull'] : true;
     if ($firstvaluenull) {
         $el->addMultiOption(null, null);
     }
     /////////////////////
     // Add Headquarters
     $bud = new Busunit_Domain_Headquarters();
     $bu = $bud->getByAppAccount(Zend_Auth::getInstance()->getIdentity()->appaccount_id);
     $el->addMultiOption($bu->getId(), $bu->getName());
     // Add Branchs
     $bud = new Busunit_Domain_Branch();
     $bu = $bud->getAll('name');
     foreach ($bu as $busunit) {
         $el->addMultiOption($busunit->getId(), $busunit->getName());
     }
     // set value
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
 }
 public function testAddElementToDisplayGroupByElementInstance()
 {
     $element = new Zend_Form_Element_Text('foo');
     $this->form->addElement($element);
     $this->form->addDisplayGroup(array($element), 'bar');
     $this->assertNotNull($this->form->getDisplayGroup('bar')->getElement('foo'));
 }
 /** THis is where they pick the duration */
 function bookingAction()
 {
     $this->layout('layout/layout-appointment-summary');
     $layoutViewModel = $this->layout();
     $progress = new ViewModel(['step' => 3]);
     $progress->setTemplate('application/progress');
     $layoutViewModel->addChild($progress, 'progress');
     $service = $this->serviceDataMapper()->find($this->params('service'));
     $durations = array();
     foreach ($service['durations'] as $duration) {
         $durations[$duration] = $this->durationLabels[$duration];
     }
     $form = new \Zend_Form();
     $form->addElement('radio', 'appointment_duration', array('label' => 'Appointment Duration', 'multiOptions' => $durations, 'separator' => ''));
     if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
         $url = $this->url()->fromRoute('make-booking', array('action' => 'booking2', 'duration' => $form->getValue('appointment_duration'), 'service' => $this->params('service'), 'day' => $this->params('day')));
         $this->redirect()->toUrl($url);
         return;
     }
     $this->viewParams['form'] = $form;
     $summary = new ViewModel($this->params()->fromRoute());
     $summary->setTemplate('application/summary');
     $layoutViewModel->addChild($summary, 'appointment_summary');
     $viewModel = new ViewModel($this->viewParams);
     $viewModel->setTemplate('application/booking');
     return $viewModel;
 }
Exemple #25
0
 /**
  * Adds an element JobFunctionId.<br/><br/>
  * Defaults:<br/>
  * name         = job_function_id<br/>
  * requires     = true<br/>
  * label        = Business unit<br/>
  * placeholder  = 'Choose a job function'<br/>
  * dimension    = 6<br/>
  * modelfield   = job_function_id<br/>
  * firstvaluenull  = true
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  */
 public function addElementJobFunctionId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'job_function_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'job_function_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Job function', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose a job function', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $firstvaluenull = isset($options['firstvaluenull']) ? $options['firstvaluenull'] : true;
     if ($firstvaluenull) {
         $el->addMultiOption(null, null);
     }
     /**
      * Add job functions
      */
     $jfd = new Staff_Domain_Jobfunction();
     $jf = $jfd->getAll('name');
     foreach ($jf as $item) {
         $el->addMultiOption($item->getId(), $item->getName());
     }
     // set value
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
 }
Exemple #26
0
 public function addElement($element, $name = null, $options = null)
 {
     switch ($element) {
         case 'checkbox':
             $options['decorators'] = $this->elementCheckboxDecorators;
             break;
         case 'multiCheckbox':
         case 'radio':
             $options['decorators'] = $this->elementRadioDecorators;
             break;
         case 'submit':
             $options['decorators'] = $this->elementSubmitDecorators;
             break;
         case 'captcha':
             $options['decorators'] = $this->elementCaptchaDecorators;
             break;
         case 'file':
             $options['decorators'] = $this->elementFileDecorators;
             break;
         case 'hidden':
             $options['decorators'] = $this->elementHiddenDecorators;
             break;
         default:
             $options['decorators'] = $this->elementDecorators;
             break;
     }
     //if ($element != 'captcha' && $element != 'file') {
     $options['decorators'][sizeof($options['decorators']) - 1][1]['id'] = 'row_' . $name;
     $options['decorators'][sizeof($options['decorators']) - 2][1]['class'] = 'label_' . $element;
     //}
     return parent::addElement($element, $name, $options);
 }
Exemple #27
0
 /**
  * Hook for node form, add extra fields
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeForm(Zend_Form &$form, &$arguments)
 {
     $item =& array_shift($arguments);
     $content_type = Zoo::getService('content')->getType($item->type);
     if ($content_type->has_parent_url == 0) {
         $path = new Zend_Form_Element_Text('rewrite_path', array('size' => 65));
         $path->setLabel('URL');
         $form->addElement($path);
         $options = array('legend' => Zoo::_("URL Rewriting"));
         $form->addDisplayGroup(array('rewrite_path'), 'rewrite_path_options', $options);
         if ($item->id > 0) {
             $factory = new Rewrite_Path_Factory();
             $path = $factory->find($item->id)->current();
             if ($path) {
                 $form->populate(array('rewrite_path' => $path->path));
             } else {
                 // Find parent's path
                 if ($item->pid && ($path = $factory->find($item->pid)->current())) {
                     $form->populate(array('rewrite_path' => $path->path . "/" . $item->id));
                 } else {
                     $form->populate(array('rewrite_path' => $item->url()));
                 }
             }
         }
     }
 }
 /**
  * This returns the form for the collections.
  *
  * @return Zend_Form
  * @author Eric Rochester <*****@*****.**>
  **/
 protected function _collectionsForm()
 {
     $ctable = $this->_helper->db->getTable('Collection');
     $private = (int) get_option('solr_search_display_private_items');
     if ($private) {
         $collections = $ctable->findAll();
     } else {
         $collections = $ctable->findBy(array('public' => 1));
     }
     $form = new Zend_Form();
     $form->setAction(url('solr-search/collections'))->setMethod('post');
     $collbox = new Zend_Form_Element_MultiCheckbox('solrexclude');
     $form->addElement($collbox);
     foreach ($collections as $c) {
         $title = metadata($c, array('Dublin Core', 'Title'));
         $collbox->addMultiOption("{$c->id}", $title);
     }
     $etable = $this->_helper->db->getTable('SolrSearchExclude');
     $excludes = array();
     foreach ($etable->findAll() as $exclude) {
         $excludes[] = "{$exclude->collection_id}";
     }
     $collbox->setValue($excludes);
     $form->addElement('submit', 'Exclude');
     return $form;
 }
Exemple #29
0
 /**
  * Генерирует форму для заполнения доп данных
  * @return Zend_Form $form Форма для завершения регистрации
  */
 public function getForm($params)
 {
     $form = new Zend_Form();
     // Устанавливаем декораторы
     $form->setAction($form->getView()->url($params, 'auth_openid_complete'))->setAttrib('id', 'zend_form');
     //Email
     $email = new Zend_Form_Element_Text('email');
     $email->setRequired(true)->addValidator('EmailAddress', false, array('domain' => false))->addValidator(new ZendExtra_Validate_Email())->setOptions(array('domain' => false))->setLabel('Email:')->setDescription($form->getView()->translate('Enter email for recieving password'))->setAttrib('onBlur', 'validate(this);');
     $form->addElement($email);
     // Кнопка "Отправить"
     $submit = new Zend_Form_Element_Text('submit');
     $html = '<dt></dt><dd><a class="btn-base btn-normal" href="javascript:;" onClick=\'$("#zend_form").submit();\'><span></span>' . $form->getView()->translate('submit') . '</a></dd>';
     $submit->setDecorators(array('decorator' => array('br' => new ZendExtra_Form_Decorator_HtmlCode(array('tag' => $html, 'placement' => Zend_Form_Decorator_Abstract::PREPEND)))))->setOrder(100);
     $form->addElement($submit);
     return $form;
 }
 /**
  * Ensures that enhance() does not modify the provided form.
  */
 public function testEnhanceDoesNotModifyForm()
 {
     $form = new Zend_Form();
     $form->addElement(new Zend_Form_Element_Text('name'));
     $this->plugin->enhance($form);
     $this->assertEquals(1, count($form->getElements()));
 }