當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。