當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Element::setAttribute方法代碼示例

本文整理匯總了PHP中Zend\Form\Element::setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Element::setAttribute方法的具體用法?PHP Element::setAttribute怎麽用?PHP Element::setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\Element的用法示例。


在下文中一共展示了Element::setAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testPassingElementToOpenTagWillUseIdInForAttributeWhenPresent

 public function testPassingElementToOpenTagWillUseIdInForAttributeWhenPresent()
 {
     $element = new Element('foo');
     $element->setAttribute('id', 'bar');
     $markup = $this->helper->openTag($element);
     $this->assertContains('for="bar"', $markup);
 }
開發者ID:haoyanfei,項目名稱:zf2,代碼行數:7,代碼來源:FormLabelTest.php

示例2: __construct

 public function __construct()
 {
     parent::__construct('nested_fieldset');
     $field = new Element('anotherField', array('label' => 'Name'));
     $field->setAttribute('type', 'text');
     $this->add($field);
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:7,代碼來源:NestedFieldset.php

示例3: testCanCreateMarkupWithoutLabel

 public function testCanCreateMarkupWithoutLabel()
 {
     $element = new Element('foo');
     $element->setAttribute('type', 'text');
     $markup = $this->helper->render($element);
     $this->assertRegexp('/<input name="foo" type="text"(\\s*\\/)?>/', $markup);
 }
開發者ID:robertodormepoco,項目名稱:zf2,代碼行數:7,代碼來源:FormRowTest.php

示例4: testRendersValueAttributeAsTextareaContent

 public function testRendersValueAttributeAsTextareaContent()
 {
     $element = new Element('foo');
     $element->setAttribute('value', 'Initial content');
     $markup = $this->helper->render($element);
     $this->assertContains('>Initial content</textarea>', $markup);
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:7,代碼來源:FormTextareaTest.php

示例5: setAttribute

 /**
  * Set a single element attribute
  * 
  * @param  string $key 
  * @param  mixed $value 
  * @return Element
  */
 public function setAttribute($key, $value)
 {
     if ('captcha' == strtolower($key)) {
         $this->setCaptcha($value);
         return $this;
     }
     return parent::setAttribute($key, $value);
 }
開發者ID:niallmccrudden,項目名稱:zf2,代碼行數:15,代碼來源:Captcha.php

示例6: testSetUseHiddenElementAttributeDoesNotRenderHiddenInput

 public function testSetUseHiddenElementAttributeDoesNotRenderHiddenInput()
 {
     $element = new Element('foo');
     $element->setAttribute('useHiddenElement', false);
     $markup = $this->helper->render($element);
     $this->assertRegexp('#type="checkbox"\\s+value="1"#', $markup);
     $this->assertNotRegexp('#type="hidden"\\s+name="foo"\\s+value="0"#', $markup);
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:8,代碼來源:FormCheckboxTest.php

示例7: setAttribute

 /**
  * Override: set a single element attribute
  *
  * Does not allow setting value attribute; this will always be
  * retrieved from the validator.
  * 
  * @param  string $name 
  * @param  mixed $value 
  * @return Csrf
  */
 public function setAttribute($name, $value)
 {
     if ('value' == $name) {
         // Do not allow setting this
         return;
     }
     return parent::setAttribute($name, $value);
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:18,代碼來源:Csrf.php

示例8: testRendersOnErrorAsEspected

 public function testRendersOnErrorAsEspected()
 {
     $element = new Element('testElement');
     $element->setAttribute('value', 'Initial Content');
     $element->setMessages(array('testElement' => 'no valid'));
     $markup = $this->helper->render($element);
     $this->assertContains('error', $markup);
 }
開發者ID:3makkk,項目名稱:Foundation,代碼行數:8,代碼來源:FormElementTest.php

示例9: testGeneratesEmailInputTagRegardlessOfElementType

 public function testGeneratesEmailInputTagRegardlessOfElementType()
 {
     $element = new Element('foo');
     $element->setAttribute('type', 'radio');
     $markup = $this->helper->render($element);
     $this->assertContains('<input ', $markup);
     $this->assertContains('type="email"', $markup);
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:8,代碼來源:FormEmailTest.php

示例10: testOpenTagOnlyAllowsValidButtonTypes

 /**
  * @dataProvider inputTypes
  */
 public function testOpenTagOnlyAllowsValidButtonTypes($type, $assertion)
 {
     $element = new Element('foo');
     $element->setAttribute('type', $type);
     $markup = $this->helper->openTag($element);
     $expected = sprintf('type="%s"', $type);
     $this->{$assertion}($expected, $markup);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:11,代碼來源:FormButtonTest.php

示例11: __construct

 public function __construct()
 {
     parent::__construct('basic_fieldset');
     $field = new Element('field', array('label' => 'Name'));
     $field->setAttribute('type', 'text');
     $this->add($field);
     $nestedFieldset = new NestedFieldset();
     $this->add($nestedFieldset);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:9,代碼來源:BasicFieldset.php

示例12: testInvokeProxiesToRender

 public function testInvokeProxiesToRender()
 {
     $element = new Element('foo');
     $element->setAttribute('src', 'foo.png');
     $markup = $this->helper->__invoke($element);
     $this->assertContains('<input', $markup);
     $this->assertContains('name="foo"', $markup);
     $this->assertContains('type="image"', $markup);
     $this->assertContains('src="foo.png"', $markup);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:10,代碼來源:FormImageTest.php

示例13: __construct

 public function __construct()
 {
     parent::__construct('test_form');
     $this->setAttribute('method', 'post')->setHydrator(new ClassMethodsHydrator());
     $field1 = new Element('name', array('label' => 'Name'));
     $field1->setAttribute('type', 'text');
     $this->add($field1);
     $field2 = new Element('email', array('label' => 'Email'));
     $field2->setAttribute('type', 'text');
     $this->add($field2);
     $this->add(array('name' => 'csrf', 'type' => 'Zend\\Form\\Element\\Csrf', 'attributes' => array()));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit')));
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:13,代碼來源:CustomForm.php

示例14: __construct

 public function __construct($name = null, $options = array())
 {
     parent::__construct("page", $options);
     $this->setAttribute("method", "post");
     $this->setAttribute("id", "pageform");
     $this->add(array("name" => "id", "attributes" => array("type" => "hidden", "value" => "0")));
     $this->add(array("name" => "article", "attributes" => array("type" => "textarea"), "options" => array("label" => "Description")));
     $title = new Element("title");
     $title->setAttribute("type", "text");
     $title->setLabel("Title");
     $this->add($title);
     $this->add(array("name" => "date", "attributes" => array("type" => "text"), "options" => array("label" => "Publication Date")));
     $this->add(array("name" => "submit", "type" => "submit", "attributes" => array("value" => "Отправить", "id" => "submitbutton", "class" => "btn")));
 }
開發者ID:seyfer,項目名稱:zend2-tutorial.me,代碼行數:14,代碼來源:ContactForm.php

示例15: __invoke

 /**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function __invoke(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'control-label'));
     $element->setAttribute('data-placement', 'bottom')->setAttribute('data-content', $element->getOption('description'));
     if (!$element->getLabel()) {
         $element->setLabel('öö');
     }
     $output = '<div class="control-group">';
     $output .= $this->getView()->formLabel($element);
     $output .= '<div class="controls">';
     $output .= $this->getView()->formElement($element);
     if ($element->getOption('description')) {
         $output .= '<div class="description">' . $element->getOption('description') . '</div>';
     }
     if ($element->getMessages()) {
         $output .= '<div class="alert alert-error">' . $this->getView()->formElementErrors($element) . '</div>';
     }
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
開發者ID:krsreenatha,項目名稱:php.ug,代碼行數:26,代碼來源:TBElement.php


注:本文中的Zend\Form\Element::setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。