本文整理汇总了PHP中Zend_Form::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::createElement方法的具体用法?PHP Zend_Form::createElement怎么用?PHP Zend_Form::createElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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
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;
}
示例4: contactFormAction
public function contactFormAction()
{
//create the form
$form = new Zend_Form();
//this page should post back to itself
$form->setAction($_SERVER['REQUEST_URI']);
$form->setMethod('post');
$name = $form->createElement('text', 'name');
$name->setLabel($this->view->getTranslation('Your Name') . ': ');
$name->setRequired(TRUE);
$name->addFilter('StripTags');
$name->addErrorMessage($this->view->getTranslation('Your name is required!'));
$name->setAttrib('size', 30);
$email = $form->createElement('text', 'email');
$email->setLabel($this->view->getTranslation('Your Email') . ': ');
$email->setRequired(TRUE);
$email->addValidator('EmailAddress');
$email->addErrorMessage($this->view->getTranslation('Invalid email address!'));
$email->setAttrib('size', 30);
$subject = $form->createElement('text', 'subject');
$subject->setLabel($this->view->getTranslation('Subject') . ': ');
$subject->setRequired(TRUE);
$subject->addFilter('StripTags');
$subject->addErrorMessage($this->view->getTranslation('The subject is required!'));
$subject->setAttrib('size', 40);
$message = $form->createElement('textarea', 'message');
$message->setLabel($this->view->getTranslation('Message') . ': ');
$message->setRequired(TRUE);
$message->addErrorMessage($this->view->getTranslation('The message is required!'));
$message->setAttrib('cols', 35);
$message->setAttrib('rows', 10);
$captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300)));
$form->addElement($name);
$form->addElement($email);
$form->addElement($subject);
$form->addElement($message);
$form->addElement($captcha);
$form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message')));
$this->view->form = $form;
if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) {
if ($form->isValid($_POST)) {
//get form data
$data = $form->getValues();
//get the module data
$module = new Digitalus_Module();
$moduleData = $module->getData();
//render the message
$this->view->data = $data;
$htmlMessage = $this->view->render('public/message.phtml');
$mail = new Digitalus_Mail();
$this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage);
}
}
}
示例5: getLoginForm
/**
* This function creates a zend form for a login box with the relevant validation
*
* @return Zend_Form
*/
protected function getLoginForm()
{
$form = new Zend_Form();
$form->setAction('/cmsadmin/login')->setMethod('post');
$username = $form->createElement('text', 'username');
$username->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(6, 64))->setRequired(true)->addFilter('StringToLower');
$password = $form->createElement('password', 'password');
$password->addValidator('StringLength', false, array(6))->setRequired(true);
$form->addElement($username)->addElement($password)->addElement('submit', 'login', array('label' => 'Login'));
return $form;
}
示例6: loginForm
public function loginForm()
{
$form = new Zend_Form();
$form->setAction('user/auth')->setMethod('post');
// Create and configure username element:
$username = $form->createElement('text', 'user_username');
$username->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(6, 20))->setRequired(true)->addFilter('StringToLower');
// Create and configure password element:
$password = $form->createElement('password', 'user_password');
$password->addValidator('StringLength', false, array(6))->setRequired(true);
// Add elements to form:
$form->addElement($username)->addElement($password)->addElement('submit', 'login', array('label' => 'Login'));
}
示例7: 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;
}
示例8: setForm
function setForm()
{
$form=new Zend_Form;
$form->setMethod('post')->setAction('');
$youtube_username = new Zend_Form_Element_Text('youtube_username');
$youtube_username->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên tài khoản không được để trống'));
$password = new Zend_Form_Element_Text('password');
$password->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống'));
$youtube_gallery = new Zend_Form_Element_Text('youtube_gallery');
$youtube_gallery->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên album không được để trống'));
$is_selected = $form->createElement("select","is_selected",array(
"label" => "Kích hoạt",
"multioptions"=> array(
"0" => "Không",
"1" => "Có")));
$youtube_username->removeDecorator('HtmlTag')->removeDecorator('Label');
$password->removeDecorator('HtmlTag')->removeDecorator('Label');
$youtube_gallery->removeDecorator('HtmlTag')->removeDecorator('Label');
$is_selected->removeDecorator('HtmlTag')->removeDecorator('Label');
$form->addElements(array($youtube_username,$password,$youtube_gallery,$is_selected));
return $form;
}
示例9: setForm
function setForm()
{
$form=new Zend_Form;
$form->setMethod('post')->setAction('');
$ads_banner = new Zend_Form_Element_Textarea('ads_banner');
$ads_banner->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Biểu ngữ không được để trống'));
$ads_position = new Zend_Form_Element_Text('ads_position');
$ads_position->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vị trí không được để trống'));
$ads_name = new Zend_Form_Element_Text('ads_name');
$ads_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên quảng cáo không được để trống'));
$ads_link = new Zend_Form_Element_Text('ads_link');
$ads_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Đường dẫn không được để trống'));
$ads_position = $form->createElement("select","ads_position",array(
"label" => "Vị trí",
"multioptions"=> array(
"1" => "Trên",
"2" => "Giữa",
"3" => "Trái",
"4" => "Phải",
"5" => "Nội dung")));
$ads_banner->removeDecorator('HtmlTag')->removeDecorator('Label');
$ads_position->removeDecorator('HtmlTag')->removeDecorator('Label');
$ads_name->removeDecorator('HtmlTag')->removeDecorator('Label');
$ads_link->removeDecorator('HtmlTag')->removeDecorator('Label');
$form->addElements(array($ads_banner,$ads_position,$ads_name,$ads_link));
return $form;
}
示例10: setForm
function setForm()
{
$form=new Zend_Form;
$form->setMethod('post')->setAction('');
$category_name = new Zend_Form_Element_Text('category_name');
$category_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên danh mục không được để trống'));
/*
$category_parent_id = new Zend_Form_Element_Select('category_parent_id');
$category_parent_id->addMultiOption('', '0');
foreach($this->mDanhmuc->getListDM() as $item)
{
$category_parent_id->addMultiOption($item['category_name'], $item['category_id']);
}
*/
$is_active = $form->createElement("select","is_active",array(
"label" => "Kích hoạt",
"multioptions"=> array(
"0" => "Chưa kích hoạt",
"1" => "Đã kích hoạt")));
$category_name->removeDecorator('HtmlTag')->removeDecorator('Label');
$is_active->removeDecorator('HtmlTag')->removeDecorator('Label');
$form->addElements(array($category_name,$is_active));
return $form;
}
示例11: adminloginForm
function adminloginForm()
{
$siteurl = 'http://' . $_SERVER['SERVER_NAME'];
$form = new Zend_Form();
$form->setAction($siteurl . '/admin/auth')->setMethod('post');
// Create and configure username element:
$username = $form->createElement('text', 'user_username');
$username->setLabel('Username');
$username->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(6, 20))->setRequired(true)->addFilter('StringToLower');
// Create and configure password element:
$password = $form->createElement('password', 'user_password');
$password->setLabel('Password');
$password->addValidator('StringLength', false, array(6))->setRequired(true);
// Add elements to form:
$form->addElement($username)->addElement($password)->addElement('submit', 'login', array('label' => 'Login', 'class' => 'noWarn'));
return $form;
}
示例12: removeAction
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();
}
}
示例13: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setAction('/index/login')->setMethod('post')->setAttrib('id', 'formLogin');
// Crea un y configura el elemento username
$username = $form->createElement('text', 'username', array('label' => 'Nombre de Usuario'));
$username->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')))->addValidator('regex', true, array('pattern' => '/^[(a-zA-Z0-9)]+$/', 'messages' => array('regexNotMatch' => 'Caracteres invalidos')))->addValidator('stringLength', false, array(5, 20, 'messages' => "5 a 20 caracteres"))->setRequired(true)->addFilter('StringToLower');
$username->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
// Crea y configura el elemento password:
$password = $form->createElement('password', 'password', array('label' => 'Contraseña'));
$password->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'Campo requerido')))->addValidator('stringLength', false, array(5, 20, 'messages' => "5 a 20 caracteres"))->setRequired(true);
$password->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('elementDiv' => 'HtmlTag'), array('tag' => 'div')), array(array('td' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))));
$recordarme = $form->createElement('checkbox', 'remember', array('label' => 'Recordar mi Sesión'));
$recordarme->setDecorators(array('ViewHelper', 'Description', 'Errors', array('Label', array('placement' => 'APPEND'))));
// Añade los elementos al formulario:
$form->addElement($username)->addElement($password)->addElement($recordarme)->addElement('submit', 'login', array('label' => 'Ingresar'));
return $form;
}
示例14: createElement
/**
* Создание элемента формы
*
* @see Zend_Form::createElement()
*/
public function createElement($type, $name, $options = null)
{
$element = parent::createElement($type, $name, $options);
//$element->removeDecorator('Label');
//$element->removeDecorator('HtmlTag');
//$element->removeDecorator('DtDdWrapper');
//$element->removeDecorator('Description');
return $element;
}
示例15: indexAction
/**
* 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");
}