/** * 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 } }
public function removeAction() { $form = new Zend_Form(); $form->setView(new Zend_View()); $form->setMethod('post'); $form->setAction(''); $form->setAttrib('class', 'devel'); $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name')); $handleOptions = explode(',', $this->getRequest()->getParam('handles')); $referenceOptions = explode(',', $this->getRequest()->getParam('references')); $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used')); $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper'))); $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper'))); $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper'))); $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used'))); $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions))); $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true)); $submit = $form->createElement('submit', 'submit', array('label' => 'Submit')); $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit)); if ($form->isValid($this->getRequest()->getParams())) { $localXmlWriter = Mage::getModel('devel/writer_localxml'); $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue()); $localXmlWriter->save(); die('DONE. You need to reload to see changes!'); } else { $this->loadLayout(); $this->getLayout()->getUpdate()->load('devel_layout_wizard'); $this->getLayout()->generateXml(); $this->loadLayout(); $this->getLayout()->getBlock('devel_wizard_form')->setForm($form); $this->renderLayout(); } }
/** * Constructor requiring Zend_Form instance to be rendered * @param Zend_Form $form */ public function __construct(Zend_Form $form, $form_id = null) { $this->form = $form; $this->form->setAttrib('class', 'form_view'); if (!is_null($form_id)) { $this->form->setAttrib('id', $form_id); } // Zend_Translate could be an option but the scope is a situation // where allready other internationalisation systems exist $this->lang = new My_LanguagePack(); }
/** * Constructor requiring Zend_Form instance to be rendered * @param Zend_Form $form */ public function __construct(Zend_Form $form, $form_id = null) { // create view and specify doctype to have self-closing tags. $view = new Zend_View(); $view->setBasePath(dirname(__FILE__)); $view->doctype('XHTML1_TRANSITIONAL'); $this->form = $form; $this->form->setView(new Zend_View()); $this->form->setAttrib('class', 'form_dynamic'); if (!is_null($form_id)) { $this->form->setAttrib('id', $form_id); } }
/** * Constructor requiring Zend_Form instance to be rendered * @param Zend_Form $form */ public function __construct(Zend_Form $form, $form_id = null) { // create view and specify doctype to have self-closing tags. $view = new Zend_View(); $view->doctype('XHTML1_TRANSITIONAL'); $this->form = $form; $this->form->setView(new Zend_View()); $this->form->setAttrib('class', 'form_edit'); if (!is_null($form_id)) { $this->form->setAttrib('id', $form_id); } // Zend_Translate could be an option but the scope is a situation // where allready other internationalisation systems exist $this->lang = new My_LanguagePack(); }
public function dojoHelperAction() { $this->_helper->layout()->setLayout('layouts/site-dojo'); $this->view->dojo()->enable()->setDjConfigOption('parseOnLoad', true)->setDjConfigOption('locale', 'en-US')->setDjConfigOption('isDebug', true)->setLocalPath('scripts/dojo/1.6/dojo/dojo.js')->addStyleSheetModule('dijit.themes.soria'); $form = new Zend_Form(); $form->setAttrib('id', 'mainform'); $form->setAttrib('class', 'siteInteraction'); $form->setAction('test/zend-forms/login')->setMethod('post'); Zend_Dojo::enableForm($form); $form->addElement('NumberTextBox', 'foo', array('type' => 'percent', 'value' => '0.1', 'label' => 'Percentage:')); $form->addElement('NumberTextBox', 'foodos', array('constraints' => array('min' => 0, 'max' => 15, 'places' => 0), 'required' => 'true', 'value' => '11', 'label' => 'Number text Box:', 'class' => '')); $form->addElement('button', 'btn', array('label' => 'SEND')); //$form->getElement('btn')->removeDecorator('DtDdWrapper'); $this->view->form = $form; }
/** * @return Zend_Form */ public function getUploadForm() { static $form; if (null === $form) { $form = new Zend_Form(); $form->setAttrib('enctype', 'multipart/form-data')->addElement('file', 'xml', array('label' => _('File'), 'required' => true, 'validators' => array('NotEmpty' => array()))); $statusOptions = ['label' => 'Status for imported concepts']; if ($this->getTenant()['enableStatusesSystem']) { $statusOptions['multiOptions'] = OpenSKOS_Concept_Status::statusesToOptions(); } else { $statusOptions['multiOptions'] = [OpenSKOS_Concept_Status::APPROVED]; $statusOptions['disabled'] = true; } $form->addElement('select', 'status', $statusOptions); $form->addElement('checkbox', 'ignoreIncomingStatus', array('label' => 'Ignore incoming status')); $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor'); $form->addElement('select', 'lang', array('label' => 'The default language to use if no "xml:lang" attribute is found', 'multiOptions' => $editorOptions['languages'])); $form->addElement('checkbox', 'toBeChecked', array('label' => 'Sets the toBeCheked status of imported concepts')); $form->addElement('checkbox', 'purge', array('label' => 'Purge. Delete all concept schemes found in the file. (will also delete concepts inside them)')); $form->addElement('checkbox', 'delete-before-import', array('label' => _('Delete concepts in this collection before import'))); $form->addElement('checkbox', 'onlyNewConcepts', array('label' => _('Import contains only new concepts. Do not update any concepts if they match by notation (or uri if useUriAsIdentifier is used).'))); $form->addElement('checkbox', 'useUriAsIdentifier', array('label' => _('Use uri as identifier if concept notation does not exist in the importing concept.'))); $form->addElement('submit', 'submit', array('label' => 'Submit')); } 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; }
/** 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; }
/** * Ensures that the plugin does not modify the autocomplete attribute if it * is already defined in the form. */ public function testPluginDoesNotModifyAutocompleteAttributeIfItIsAlreadyDefinedInTheForm() { $form = new Zend_Form(); $form->setAttrib('autocomplete', 'any-value'); $this->plugin->enhance($form); $this->assertEquals('any-value', $form->getAttrib('autocomplete')); }
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; }
public function testCanAddAndRetrieveMultipleAttribs() { $this->form->setAttrib('foo', 'bar'); $this->assertEquals('bar', $this->form->getAttrib('foo')); $this->form->addAttribs(array('bar' => 'baz', 'baz' => 'bat', 'bat' => 'foo')); $test = $this->form->getAttribs(); $attribs = array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'bat', 'bat' => 'foo'); $this->assertSame($attribs, $test); }
/** * Sets the autocomplete attribute of given form to "off". * * The plugin will not modify the form if it already has * an autocomplete attribute. * * @param Zend_Form $form */ public function enhance(Zend_Form $form) { if ($form->getAttrib('autocomplete') !== null) { // Autocomplete attribute is already set for // this form instance. return; } $form->setAttrib('autocomplete', 'off'); }
public function formAction() { $form = new Zend_Form(); $form->setAction('/resource/process')->setMethod('post'); $form->setAttrib('id', 'login'); $form->addElement('text', 'username'); echo $form; exit; }
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); }
/** 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 form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'reportingForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $fromDate = $form->createElement('text', 'fromDate', array('label' => 'reporting-index-index:fromDate')); $fromDate->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['fromDate']) ? $values['fromDate'] : ''); $toDate = $form->createElement('text', 'toDate', array('label' => 'reporting-index-index:toDate')); $toDate->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['toDate']) ? $values['toDate'] : strftime('%B %e, %Y', time())); $submit = $form->createElement('submit', 'submitButton', array('label' => 'reporting-index-index:getReport')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($fromDate, $toDate)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); return $form; }
/** * initForm * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ protected function initForm() { $this->objForm = new Zend_Form(); /** * Use our own PluginLoader */ $objLoader = new PluginLoader(); $objLoader->setPluginLoader($this->objForm->getPluginLoader(PluginLoader::TYPE_FORM_ELEMENT)); $objLoader->setPluginType(PluginLoader::TYPE_FORM_ELEMENT); $this->objForm->setPluginLoader($objLoader, PluginLoader::TYPE_FORM_ELEMENT); /** * clear all decorators */ $this->objForm->clearDecorators(); /** * add standard decorators */ $this->objForm->addDecorator('TabContainer'); $this->objForm->addDecorator('FormElements'); $this->objForm->addDecorator('Form'); /** * add form prefix path */ $this->objForm->addPrefixPath('Form_Decorator', GLOBAL_ROOT_PATH . 'library/massiveart/generic/forms/decorators/', 'decorator'); /** * elements prefixes */ $this->objForm->addElementPrefixPath('Form_Decorator', GLOBAL_ROOT_PATH . 'library/massiveart/generic/forms/decorators/', 'decorator'); /** * regions prefixes */ $this->objForm->addDisplayGroupPrefixPath('Form_Decorator', GLOBAL_ROOT_PATH . 'library/massiveart/generic/forms/decorators/'); $this->objForm->setAttrib('id', 'genForm'); $this->objForm->setAttrib('onsubmit', 'return false;'); $this->objForm->addElement('hidden', 'id', array('decorators' => array('Hidden'))); $this->objForm->addElement('text', 'title', array('label' => $this->core->translate->_('title', false), 'decorators' => array('Input'), 'columns' => 12, 'class' => 'text keyfield', 'required' => true)); $this->objForm->addElement('text', 'key', array('label' => $this->core->translate->_('key', false), 'decorators' => array('Input'), 'columns' => 12, 'class' => 'text', 'required' => true)); $this->objForm->addDisplayGroup(array('title', 'key'), 'main-resource'); $this->objForm->getDisplayGroup('main-resource')->setLegend($this->core->translate->_('General_information', false)); $this->objForm->getDisplayGroup('main-resource')->setDecorators(array('FormElements', 'Region')); $arrGroups = array(); $sqlStmt = $this->core->dbh->query("SELECT `id`, `title` FROM `groups` ORDER BY `title`")->fetchAll(); foreach ($sqlStmt as $arrSql) { $arrGroups[$arrSql['id']] = $arrSql['title']; } $this->objForm->addElement('multiCheckbox', 'groups', array('label' => $this->core->translate->_('groups', false), 'value' => $this->arrGroups, 'decorators' => array('Input'), 'columns' => 6, 'class' => 'multiCheckbox', 'MultiOptions' => $arrGroups)); $this->objForm->addDisplayGroup(array('groups'), 'groups-group'); $this->objForm->getDisplayGroup('groups-group')->setLegend($this->core->translate->_('Resource_groups', false)); $this->objForm->getDisplayGroup('groups-group')->setDecorators(array('FormElements', 'Region')); }
public function addAttendeeForm($values = array()) { if (!isset($values['eventId'])) { throw new Ot_Exception_Input('The event ID must be provided.'); } $form = new Zend_Form(); $form->setAttrib('id', 'locationForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $eventId = $form->createElement('hidden', 'eventId'); $eventId->setValue($values['eventId']); $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($eventId); $type = $form->createElement('select', 'type', array('label' => 'How to Add:')); $type->addMultiOption('firstAvailable', 'First Available Spot')->addMultiOption('attending', 'Add To Attending List')->setValue(isset($values['type']) ? $values['type'] : ''); // get all the users available for the instructor list $otAccount = new Ot_Account(); $accounts = $otAccount->fetchAll(null, array('lastName', 'firstName'))->toArray(); $userList = array(); foreach ($accounts as $a) { $userList[$a['accountId']] = $a['lastName'] . ", " . $a['firstName']; } // remove anyone who's either in the attendee list, waitlist, or an instructor // for this event so they can't be added to the list $attendee = new Event_Attendee(); $attendeeList = $attendee->getAttendeesForEvent($values['eventId'], 'attending'); $waitlist = $attendee->getAttendeesForEvent($values['eventId'], 'waitlist'); $instructors = $this->getInstructorsForEvent($values['eventId']); foreach ($attendeeList as $a) { unset($userList[$a['accountId']]); } foreach ($waitlist as $w) { unset($userList[$w['accountId']]); } foreach ($instructors as $i) { unset($userList[$i['accountId']]); } $users = $form->createElement('multiselect', 'users', array('label' => 'User Search:')); $users->setMultiOptions($userList)->setAttrib('size', 10)->setValue(isset($values['accountIds']) ? $values['accountIds'] : ''); $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->addElements(array($type, $users)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); return $form; }
/** * The main workshop page. It has the list of all the workshops that are * available in the system. * */ public function indexAction() { $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list')); $get = Zend_Registry::get('getFilter'); $form = new Zend_Form(); $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form')); $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops')); $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : ''); $category = new Category(); $categoryList = $category->fetchAll(null, 'name'); $categories = $form->createElement('select', 'categoryId'); $categories->addMultiOption('', '-- Search By Category -- '); foreach ($categoryList as $c) { $categories->addMultiOption($c['categoryId'], $c['name']); } $categories->setValue(isset($get->categoryId) ? $get->categoryId : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($searchField, $categories)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); $this->view->form = $form; $searchTerm = new Search_Term(); $workshops = array(); if ($get->search != '' || $get->categoryId != 0) { $workshop = new Workshop(); $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); if ($get->search != '') { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true); } if ($get->categoryId != 0) { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true); } $workshops = $workshop->search($query); $searchTerm->increment($get->search); $this->view->searchTerm = $get->search; } $this->view->workshops = $workshops; $this->view->topTerms = $searchTerm->getTopSearchTerms(10); $this->view->layout()->setLayout('search'); $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml'); $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css'); $this->_helper->pageTitle("workshop-index-index:title"); }
/** * @return Zend_Form * @throws Zend_Form_Exception */ public function getForm() { $checkoutForm = new Zend_Form(); $checkoutForm->setAction('/checkout')->setMethod('post'); $checkoutForm->setAttrib('id', 'checkout'); $firstName = new Zend_Form_Element_Text('first_name'); $firstName->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('First Name'); $checkoutForm->addElement($firstName); $lastName = new Zend_Form_Element_Text('last_name'); $lastName->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Last Name'); $checkoutForm->addElement($lastName); $propertyNumber = new Zend_Form_Element_Text('property_number'); $propertyNumber->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Property Number'); $checkoutForm->addElement($propertyNumber); $addressLine1 = new Zend_Form_Element_Text('address_line_1'); $addressLine1->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Address Line 1'); $checkoutForm->addElement($addressLine1); $addressLine2 = new Zend_Form_Element_Text('address_line_2'); $addressLine2->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Address Line 2'); $checkoutForm->addElement($addressLine2); $city = new Zend_Form_Element_Text('city'); $city->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('City'); $checkoutForm->addElement($city); $county = new Zend_Form_Element_Text('county'); $county->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('County'); $checkoutForm->addElement($county); $postcode = new Zend_Form_Element_Text('postcode'); $postcode->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Postcode'); $checkoutForm->addElement($postcode); $phoneNumber = new Zend_Form_Element_Text('phone_number'); $phoneNumber->addValidator(new Zend_Validate_Digits(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Phone Number'); $checkoutForm->addElement($phoneNumber); $cardNumber = new Zend_Form_Element_Text('card_number'); $cardNumber->addValidator(new Zend_Validate_Digits(array('allowWhiteSpace' => true)))->setRequired(true)->setLabel('Card Number'); $checkoutForm->addElement($cardNumber); $securityCode = new Zend_Form_Element_Text('security_code'); $securityCode->addValidator(new Zend_Validate_Digits())->setRequired(true)->setLabel('Security Code'); $checkoutForm->addElement($securityCode); $expirationDate = new Zend_Form_Element_Text('expiration_date'); $expirationDate->addValidator(new Zend_Validate_Date('MM/YYYY'))->setRequired(true)->setLabel('Expiration Date'); $checkoutForm->addElement($expirationDate); $checkoutForm->addElement(new Zend_Form_Element_Submit('checkout')); return $checkoutForm; }
public function historyAction() { $account = new Ot_Account(); $thisAccount = Zend_Auth::getInstance()->getIdentity(); $get = Zend_Registry::get('getFilter'); if (isset($get->accountId)) { if ($this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')) { $thisAccount = $account->find($get->accountId); } if (is_null($thisAccount)) { throw new Ot_Exception_Data('msg-error-accountNotFound'); } } if (is_null($thisAccount)) { throw new Ot_Exception_Data('msg-error-notLoggedIn'); } $this->view->acl = array('editAllReservations' => $this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')); $form = new Zend_Form(); $form->setAttrib('id', 'accountForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form')); $accountSelect = $form->createElement('select', 'accountId', array('label' => 'default-index-history:viewReservations')); $accountSelect->setRequired(false); $account = new Ot_Account(); $accounts = $account->fetchAll(null, array('lastName', 'firstName')); foreach ($accounts as $a) { $accountSelect->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')'); } $submit = $form->createElement('submit', 'submitButton', array('label' => 'default-index-history:lookup')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($accountSelect)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); $this->view->form = $form; $event = new Event(); $myEvents = $event->getEventsForUser($thisAccount->accountId); $this->view->myEvents = $myEvents['currentEvents']; $this->view->myPastEvents = $myEvents['pastEvents']; $this->view->account = $thisAccount->toArray(); $this->view->hideFeature = true; $this->_helper->layout->setLayout('my'); $this->view->messages = $this->_helper->flashMessenger->getMessages(); $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css'); }
public function __construct($options = array()) { parent::__construct($options); $acl = Zend_Registry::get('acl'); $form = new Zend_Form(); $form->setAttrib('id', 'account')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $authAdapter = new Ot_Model_DbTable_AuthAdapter(); $adapters = $authAdapter->fetchAll(null, 'displayOrder'); // Realm Select box $realmSelect = $form->createElement('select', 'realm', array('label' => 'Login Method')); foreach ($adapters as $adapter) { $realmSelect->addMultiOption($adapter->adapterKey, $adapter->name . (!$adapter->enabled ? ' (Disabled)' : '')); } $realmSelect->setValue(isset($default['realm']) ? $default['realm'] : ''); // Create and configure username element: $username = $form->createElement('text', 'username', array('label' => 'model-account-username')); $username->setRequired(true)->addFilter('StringTrim')->addFilter('Alnum')->addFilter('StripTags')->addValidator('StringLength', false, array(3, 64))->setAttrib('maxlength', '64')->setValue(isset($default['username']) ? $default['username'] : ''); $submit = $form->createElement('submit', 'submit', array('label' => 'Masquerade')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($realmSelect, $username, $submit)); }
public function setcategoryAction() { $form = new Zend_Form(); $form->setAction(PUBLIC_PATH . $this->getRequest()->getControllerName() . '/setcategory/'); $form->setMethod('post'); $form->setAttrib('id', 'CategoryForm'); $type = new Zend_Form_Element_Select('Categorie'); //$type->setLabel('Choisissez la catégorie de vos saisies'); $type->setRequired(true); $table = new Categories(); $select = $table->select(); $objects = $table->fetchAll($select); foreach ($objects as $object) { $type->addMultiOption($object->Id, $object->Name); } if (!empty($this->session->category)) { $type->setValue($this->session->category); } else { $type->setValue($objects[0]->Id); } $type->setDecorators(array('ViewHelper', 'Description', 'Errors', array('HtmlTag', array('tag' => 'dd', 'class' => 'PositionCenter')))); $submit = new Zend_Form_Element_Submit('Enregistrer'); $form->addElement($type); $form->addElement($submit); if ($this->getRequest()->isPost() && $form->isValid($_POST)) { $values = $form->getValues(); $row = $table->find($values['Categorie'])->current(); unset($_COOKIE['PreviousCategory']); setcookie('PreviousCategory', $row->Id, time() + 365 * 24 * 60 * 60, '/'); $this->session->category = $row->Id; $this->session->categoryName = $row->Name; $this->session->message = '<div class = "success">Vos saisies seront désormais pris en compte et rentrés dans la catégorie <strong>' . $row->Name . '</strong></div>'; return $this->_forward('index'); } else { $this->rememberCategory(); $this->view->message .= '<div class = "notice">Choisissez le métier sur lequel vous souhaitez travailler</div>'; $this->view->form = $form; return $this->render('form'); } }
/** * Gets the form for adding and editing a location * * @param array $values * @return Zend_Form */ public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'locationTypeForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $name = $form->createElement('text', 'name', array('label' => 'Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : ''); // $status = $form->createElement('select', 'status', array('label' => 'Status:')); // $status->addMultiOption('enabled', 'Enabled'); // $status->addMultiOption('disabled', 'Disabled'); // $status->setValue((isset($values['status']) ? $values['status'] : 'enabled')); // $capacity = $form->createElement('text', 'capacity', array('label' => 'Capacity:')); // $capacity->setRequired(true) // ->addFilter('StringTrim') // ->addFilter('StripTags') // ->addValidator('Digits') // ->setAttrib('maxlength', '64') // ->setValue((isset($values['capacity']) ? $values['capacity'] : '')); // $address = $form->createElement('text', 'address', array('label' => 'Address:')); // $address->setRequired(true) // ->addFilter('StringTrim') // ->addFilter('StripTags') // ->setAttrib('maxlength', '255') // ->setValue((isset($values['address']) ? $values['address'] : '')); $description = $form->createElement('textarea', 'description', array('label' => 'Description:')); $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : ''); $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->addElements(array($name, $description)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['typeId'])) { $locationId = $form->createElement('hidden', 'typeId'); $locationId->setValue($values['typeId']); $locationId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($locationId); } return $form; }
/** * @return Zend_Form */ public function getUploadForm() { static $form; if (null === $form) { $form = new Zend_Form(); $form->setAttrib('enctype', 'multipart/form-data')->addElement('file', 'xml', array('label' => _('File'), 'required' => true, 'validators' => array('NotEmpty' => array()))); $availableStatuses = array(); $availableStatuses[] = 'candidate'; $availableStatuses[] = 'approved'; $availableStatuses[] = 'expired'; $form->addElement('select', 'status', array('label' => 'Status for imported concepts', 'multiOptions' => array_combine($availableStatuses, $availableStatuses))); $form->addElement('checkbox', 'ignoreIncomingStatus', array('label' => 'Ignore incoming status')); $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor'); $form->addElement('select', 'lang', array('label' => 'The default language to use if no "xml:lang" attribute is found', 'multiOptions' => $editorOptions['languages'])); $form->addElement('checkbox', 'toBeChecked', array('label' => 'Sets the toBeCheked status of imported concepts')); $form->addElement('checkbox', 'purge', array('label' => 'Purge. Delete all concept schemes found in the file. (will also delete concepts inside them)')); $form->addElement('checkbox', 'delete-before-import', array('label' => _('Delete concepts in this collection before import'))); $form->addElement('checkbox', 'onlyNewConcepts', array('label' => _('Import contains only new concepts. Do not update any concepts if they match by notation.'))); $form->addElement('submit', 'submit', array('label' => 'Submit')); } return $form; }
public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'categoryForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $name = $form->createElement('text', 'name', array('label' => 'Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : ''); $description = $form->createElement('textarea', 'description', array('label' => 'Description:')); $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : ''); $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->addElements(array($name, $description)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['categoryId'])) { $categoryId = $form->createElement('hidden', 'categoryId'); $categoryId->setValue($values['categoryId']); $categoryId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($categoryId); } return $form; }
/** * Gets the form for adding and editing a document * * @param array $values * @return Zend_Form */ public function form($values = array()) { $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')); $name = $form->createElement('text', 'name', array('label' => 'Link Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['name']) ? $values['name'] : ''); $url = $form->createElement('text', 'url', array('label' => 'URL:')); $url->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '5000')->setValue(isset($values['url']) ? $values['url'] : ''); $form->addElements(array($name, $url)); $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)); if (isset($values['workshopLinkId'])) { $workshopLinkId = $form->createElement('hidden', 'workshopLinkId'); $workshopLinkId->setValue($values['workshopLinkId']); $workshopLinkId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($workshopLinkId); } return $form; }
public function buildLoginForm($redirect = false) { try { $form = new Zend_Form(); $form->setView($this->tpl); $form->setAttrib('class', 'form-inline'); $form->removeDecorator('dl'); $form->setAction($this->config->host->folder . '/dologin')->setMethod('post'); if ($redirect) { $redir = new Zend_Form_Element_Hidden('redirect'); $redir->setValue($redirect); $form->addElement($redir); } $username = new Zend_Form_Element_Text('username'); $username->setDecorators(array("ViewHelper")); $username->setAttrib('class', 'input-medium'); $username->setAttrib('placeholder', $this->t('Username')); $username->addValidator('regex', false, array('/^[a-z]/i')); $username->setLabel($this->t('Username')); $username->setRequired(true); $username->addFilter('StringtoLower'); $password = $form->createElement('password', 'password'); $password->setDecorators(array("ViewHelper")); $password->setAttrib('class', 'input-medium'); $username->setLabel($this->t('Password')); $password->addValidator('StringLength', false, array(6))->setRequired(true); $submit = new Zend_Form_Element_Submit('login'); $submit->setAttrib('class', 'btn'); $submit->setDecorators(array("ViewHelper")); $submit->setLabel($this->t('Login')); $form->addElement($username)->addElement($password)->addElement($submit); $form = $this->doQoolHook('post_loginform_create', $form); $this->toTpl('loginForm', $form); } catch (Exception $e) { echo $e->getMessage(); } }
function getLoginForm($redirect) { $form = new Zend_Form(); $form->setView($this->tpl); $form->setAttrib('class', 'form-inline'); $form->removeDecorator('dl'); $form->setAction($this->config->host->folder . '/dologin')->setMethod('post'); if ($redirect) { $redir = new Zend_Form_Element_Hidden('redirect'); $redir->setValue($redirect); $redir->setLabel($this->t('This action requires you login')); $form->addElement($redir); } $username = new Zend_Form_Element_Text('username'); $username->setDecorators(array("ViewHelper")); $username->setAttrib('class', 'input-medium'); $username->setAttrib('placeholder', $this->language['Username']); $username->addValidator('regex', false, array('/^[a-z]/i')); $username->setLabel($this->language['Username']); $username->setRequired(true); $username->addFilter('StringtoLower'); $password = $form->createElement('password', 'password'); $password->setDecorators(array("ViewHelper")); $password->setAttrib('class', 'input-medium'); $username->setLabel($this->language['Password']); $password->addValidator('StringLength', false, array(6))->setRequired(true); $submit = new Zend_Form_Element_Submit('login'); $submit->setAttrib('class', 'btn'); $submit->setDecorators(array("ViewHelper")); $submit->setLabel($this->t('Login')); $form->addElement($username)->addElement($password)->addElement($submit); return $form; }