本文整理汇总了PHP中Zend_Form::addElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::addElement方法的具体用法?PHP Zend_Form::addElement怎么用?PHP Zend_Form::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nodeForm
/**
* 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
}
}
示例2: getAddContentForm
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;
}
示例3: 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;
}
示例4: form
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;
}
示例5: createAssetstoreForm
/** 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;
}
示例6: createForm
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;
}
示例7: getForm
/**
* 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;
}
示例8: addLinkFormElement
/**
* 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);
}
示例9: indexAction
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);
}
示例10: getForm
/**
* 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;
}
示例11: _getForm
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;
}
示例12: addFormElements
/**
* 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);
}
示例13: staffSelector
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;
}
示例14: getForm
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;
}
示例15: createMigrateForm
/** 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;
}