当前位置: 首页>>代码示例>>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;未经允许,请勿转载。