本文整理汇总了PHP中Zend_Form::setView方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::setView方法的具体用法?PHP Zend_Form::setView怎么用?PHP Zend_Form::setView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::setView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
}
示例2: __construct
/**
* 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();
}
示例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: 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();
}
}
示例5: setView
/**
* Method to allow non-MVC usage of Zend_Form so the
* elements actually render correctly
*
* @param Zend_View_Interface $view
*/
public function setView(Zend_View_Interface $view = null)
{
parent::setView($view);
foreach ($this->getElements() as $item) {
$item->setView($view);
}
return $this;
}
示例6: setView
/**
* Set the view object
*
* Ensures that the view object has the dojo view helper path set.
*
* @param Zend_View_Interface $view
* @return Zend_Dojo_Form_Element_Dijit
*/
public function setView(Zend_View_Interface $view = null)
{
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
$view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
}
}
return parent::setView($view);
}
示例7: 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);
}
示例8: setupForm
public function setupForm()
{
$form1 = new Zend_Form_SubForm();
$form1->addElement('text', 'foo', array('label' => 'Sub Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('label' => 'Sub Bar: ', 'required' => true, 'validators' => array('Alpha', 'Alnum')));
$form2 = new Zend_Form();
$form2->addElement('text', 'foo', array('label' => 'Master Foo: ', 'required' => true, 'validators' => array('NotEmpty', 'Alpha')))->addElement('text', 'bar', array('required' => true, 'validators' => array('Alpha', 'Alnum')))->addSubForm($form1, 'sub');
$form2->isValid(array('foo' => '', 'bar' => 'foo 2 u 2', 'sub' => array('foo' => '', 'bar' => 'foo 2 u 2')));
$form2->setView($this->getView());
$this->decorator->setElement($form2);
$this->form = $form2;
return $form2;
}
示例9: testFormEnableShouldIncludeElementsOnRender
public function testFormEnableShouldIncludeElementsOnRender()
{
$view = new Zend_View();
$form = new Zend_Form();
$element = new ZendX_JQuery_Form_Element_Spinner("spinner1");
$form->setView($view);
$form->addElement($element);
ZendX_JQuery::enableForm($form);
$this->assertFalse($form->getElement('spinner1')->getView() instanceof Zend_View);
$form->render();
$this->assertTrue($form->getElement('spinner1')->getView() instanceof Zend_View);
$this->assertTrue(false !== $form->getElement('spinner1')->getView()->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper'));
}
示例10: testFormShouldOverloadToRenderDecorators
/**
* @group ZF-3217
*/
public function testFormShouldOverloadToRenderDecorators()
{
$this->setupElements();
$this->form->setView($this->getView());
$html = $this->form->renderFormElements();
foreach ($this->form->getElements() as $element) {
$this->assertContains('id="' . $element->getFullyQualifiedName() . '"', $html, 'Received: ' . $html);
}
$this->assertNotContains('<dl', $html);
$this->assertNotContains('<form', $html);
$html = $this->form->renderFormDecorator('this is the content');
$this->assertContains('<form', $html);
$this->assertContains('</form>', $html);
$this->assertContains('this is the content', $html);
}
示例11: profileForm
/**
* Checks and performs login
* @param $app Application
* @return string
*/
public function profileForm(Application $app)
{
$this->checkAuth($app);
$username = $app["user"]->getUserName();
$db = $app["db"];
$user = $db->fetchAssoc("SELECT * FROM users WHERE login_name = ? ", [$username]);
$view = new \Zend_View();
$form = new \Zend_Form();
$form->setView($view);
$form->setAction("/user/save");
$form->addElement("text", "login_name", ["label" => "Kullanıcı Adı", "required" => true])->setDefault("login_name", $user["login_name"]);
$form->addElement("password", "login_pass", ["label" => "Şifre", "required" => true]);
$form->addElement("password", "login_pass_again", ["label" => "Şifre Tekrar", "required" => true]);
$form->addElement("text", "user_name", ["label" => "Ad Soyad", "required" => true])->setDefault("user_name", $user["user_name"]);
$form->addElement("submit", "submit", ["ignore" => true, "label" => "Kaydet"]);
return $app['twig']->render('user/profile_form.html.twig', ["user" => $user, "form" => $form]);
}
示例12: mailtoAction
/**
* Creates a form for email sending and assigns it to the template or displays it
*
*/
public function mailtoAction()
{
$this->totpl('theInclude', 'general');
Zend_Registry::set('module', 'Mailto User');
$data = $this->_request->getParams();
$form = new Zend_Form();
$form->setView($this->tpl);
$form->setAttrib('class', 'form');
$form->removeDecorator('dl');
$form->setAction($this->config->host->folder . '/admin/mailtouser')->setMethod('post');
$addon = new Zend_Form_Element_Hidden('fid');
$addon->setValue($data['id']);
$form->addElement($addon);
$form->addElement($this->getFormElement(array("name" => 'tomail', "value" => 'textinput', "title" => $this->t("To mail")), $data['mail']));
$form->addElement($this->getFormElement(array("name" => 'cc', "value" => 'textinput', "title" => $this->t("MailCC"))));
$form->addElement($this->getFormElement(array("name" => 'subject', "value" => 'textinput', "title" => $this->t("Subject"))));
$form->addElement($this->getFormElement(array("name" => 'message', "value" => 'editor', "title" => $this->t("Message"), 'attributes' => array('class' => 'editor span5', 'rows' => 8))));
$form->addElement('hidden', 'dummy', array('required' => false, 'ignore' => true, 'autoInsertNotEmptyValidator' => false, 'decorators' => array(array('HtmlTag', array('tag' => 'hr', 'id' => 'wmd-button-bar', 'class' => 'divider')))));
$form->dummy->clearValidators();
$submit = new Zend_Form_Element_Submit('save');
$submit->setAttrib('class', 'btn btn-primary');
$submit->setDecorators(array("ViewHelper"));
$submit->setLabel($this->t("Send"));
$form->addElement($submit);
if ($data['ajaxcalled']) {
echo $form;
die;
}
$this->totpl('html', $form);
}
示例13: getForm
public function getForm()
{
$form = new Zend_Form();
$form->setName($this->poClass . "_form");
$schema = $this->schema->getSchema();
foreach ($this->getEditableProperties() as $propertyName => $property) {
$methodName = 'get' . ucfirst($propertyName) . 'Element';
if (method_exists($this, $methodName)) {
$form->addElement($this->{$methodName}());
continue;
}
$dbField = $schema[$this->poDef->table]->fields[$property->columnName];
$dbType = $dbField->type;
switch ($dbType) {
case 'integer':
case 'timestamp':
case 'boolean':
$element = new Zend_Form_Element_Text($propertyName);
$element->addValidator('allnum');
$element->addFilter('int');
break;
case 'float':
case 'decimal':
$element = new Zend_Form_Element_Text($propertyName);
break;
case 'blob':
case 'clob':
$element = new Zend_Form_Element_Textarea($propertyName);
break;
case 'text':
case 'time':
case 'date':
default:
$element = new Zend_Form_Element_Text($propertyName);
break;
}
if (list($relatedClassName, $relationDef) = $this->isFK($property->columnName)) {
$element = new Zend_Form_Element_Select($propertyName);
$pos = ezcPersistentSessionInstance::get();
$q = $pos->createFindQuery($relatedClassName);
$this->queryHook($q);
$list = $pos->find($q, $relatedClassName);
$element->options = $list;
$element->addFilter('int');
}
if (!$this->isNullProperty($property->columnName, $this->poDef->table)) {
$element->setRequired(true)->addValidator('NotEmpty');
}
$element->setLabel($propertyName);
$form->addElement($element);
}
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit');
$form->addElement($submit);
$form->clearDecorators();
$form->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => '<ul>'))->addDecorator('Form');
$form->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Description'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'li', 'class' => 'element-group'))));
// buttons do not need labels
$submit->setDecorators(array(array('ViewHelper'), array('Description'), array('HtmlTag', array('tag' => 'li', 'class' => 'submit-group'))));
$form->setView(new Zend_View());
return $form;
}
示例14: testSubFormGetsUniqueIdWithName
/**
* @group ZF-2950
*/
public function testSubFormGetsUniqueIdWithName()
{
$form = new Zend_Form();
$form->setView($this->getView())->setName('testform')->addSubForm(new Zend_Form_SubForm(), 'testform');
$html = $form->render();
$this->assertContains('<dt id="testform-label"> </dt>', $html);
$this->assertContains('<dd id="testform-element">', $html);
}
示例15: form
function form()
{
$form = new Zend_Form();
$form->setView(new Zend_View());
$form->addElement('text', 'api_token', array('label' => 'API Token', 'required' => true, 'value' => $this->getConfig()->vfdata->api_token));
$form->addElement('submit', 'save', array('label' => 'Save'));
return $form;
}