当前位置: 首页>>代码示例>>PHP>>正文


PHP Element::setAttribute方法代码示例

本文整理汇总了PHP中Element::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setAttribute方法的具体用法?PHP Element::setAttribute怎么用?PHP Element::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element::setAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setAttribute

 public function setAttribute($key, $value)
 {
     if ('value' === $key) {
         $this->selected = (int) $value;
     }
     parent::setAttribute($key, $value);
 }
开发者ID:vascowhite,项目名称:forms,代码行数:7,代码来源:Single.php

示例2: setAttribute

 /**
  * Handles the value attribute. If the "value" attribute is set,
  * the option with the attribute's value is then selected.
  * @param $name the name of the attribute
  * @param $value the value of the attribute
  */
 public function setAttribute($name, $value)
 {
     if (strtolower($name) == 'value') {
         $this->setSelectedOption($value);
     } else {
         parent::setAttribute($name, $value);
     }
 }
开发者ID:Attibee,项目名称:Bumble-Form,代码行数:14,代码来源:Select.php

示例3: setAttribute

 /**
  * Handles the special case of label. The label is the inner text of the <option> tag.
  * @param $name The name of the attribute.
  * @param $value The value of the attribute.
  */
 public function setAttribute($name, $value)
 {
     if ($name == 'label') {
         $this->setLabel((string) $value);
     } else {
         parent::setAttribute($name, $value);
     }
 }
开发者ID:Attibee,项目名称:defunct-dont-use,代码行数:13,代码来源:Option.php

示例4: addElement

 public function addElement(Element $element)
 {
     $element->setForm($this);
     //If the element doesn't have a specified id, a generic identifier is applied.
     $id = $element->getAttribute("id");
     $name = $element->getAttribute("name");
     if (empty($id) && $name) {
         $element->setAttribute("id", $name);
     } elseif (empty($id)) {
         $element->setAttribute("id", $this->attributes["id"] . "-element-" . sizeof($this->elements));
     }
     $this->elements[] = $element;
     /*For ease-of-use, the form tag's encytype attribute is automatically set if the File element
       class is added.*/
     if ($element instanceof Element\File) {
         $this->attributes["enctype"] = "multipart/form-data";
     }
 }
开发者ID:burakcakirel,项目名称:form,代码行数:18,代码来源:Form.php

示例5: setAttribute

 /**
  * Adds the functionality of setting the 'value' to the textarea's inner {@link TextNode}.
  * @param $attr the attribute name
  * @param $value the attribute value
  */
 public function setAttribute($attr, $value)
 {
     //value is the text node
     //we add this for the sake of consistency amongst other form elements
     if (strtolower($attr) == 'value') {
         $this->setText($value);
     } else {
         parent::setAttribute($attr, $value);
     }
 }
开发者ID:Attibee,项目名称:defunct-dont-use,代码行数:15,代码来源:Textarea.php

示例6: testSetAttribute

 /** Tests for {@link Element::setAttribute}. */
 public function testSetAttribute()
 {
     $e = new Element('div');
     $this->assertSame(0, count($e->getAttributes()), 'Set of attributes not empty for new Element.');
     $e->setAttribute('lang', 'nl');
     $a = $e->getAttributes();
     $this->assertSame(1, count($a), 'Attribute not added to Element.');
     $this->assertSame('nl', $a['lang'], 'Attribute value incorrect.');
     $e->setAttribute('lang', 'nl-be');
     $a = $e->getAttributes();
     $this->assertSame(1, count($a), 'Attribute not replaced.');
     $this->assertSame('nl-be', $a['lang'], 'Replaced attribute has incorrect value.');
 }
开发者ID:kwebble,项目名称:hadroton,代码行数:14,代码来源:ElementTest.php


注:本文中的Element::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。