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


PHP Element::create方法代碼示例

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


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

示例1: testGetSelectOptions

 public function testGetSelectOptions()
 {
     $select = $this->former->select('foo')->options($this->options);
     foreach ($this->options as $key => $option) {
         $options[$key] = Element::create('option', $option, array('value' => $key));
     }
     $this->assertEquals($select->getOptions(), $options);
 }
開發者ID:aleguisf,項目名稱:fvdev1,代碼行數:8,代碼來源:SelectTest.php

示例2: createLabel

 /**
  * Create a label element from a string
  *
  * @param string $label
  * @param string $field
  *
  * @return Element
  */
 protected function createLabel($label, $field = null)
 {
     if ($label instanceof Element) {
         $label = $label->getValue();
     }
     $label = Helpers::translate($label);
     $label = Element::create('label', $label)->for($field ?: strtolower($label));
     $label->addClass($this->app['former.framework']->getLabelClasses());
     return $label;
 }
開發者ID:dvlpp,項目名稱:warkham,代碼行數:18,代碼來源:AbstractGroupField.php

示例3: render

 /**
  * @return string
  */
 public function render()
 {
     $label = Element::label($this->label)->for($this->id);
     if ($this->inputCheckable) {
         $p = Element::create($this->container)->nest(['field' => parent::render(), 'label' => $label, 'close' => '<br>']);
     } else {
         $p = Element::create($this->container)->nest(['label' => $label, 'field' => parent::render()]);
     }
     return $p->render();
 }
開發者ID:potterywp,項目名稱:potter,代碼行數:13,代碼來源:Field.php

示例4: addChoice

 /**
  * @param string|array $_choice
  * @param string       $_value
  *
  * @return $this
  */
 public function addChoice($_choice, $_value = null)
 {
     if (is_array($_choice)) {
         $text = array_get($_choice, 'label');
         $value = array_get($_choice, 'value');
         $atts = array_except($_choice, ['label']);
     } else {
         $text = $_choice;
         $value = is_null($_value) ? $_choice : $_value;
         $atts = ['value' => $value];
     }
     $choice = Element::create('option', $text);
     $choice->setAttributes($atts);
     if ($this->isSelected($value)) {
         $choice->setAttribute('selected', 'selected');
     }
     $this->choices->push($choice);
     return $this;
 }
開發者ID:potterywp,項目名稱:potter,代碼行數:25,代碼來源:Select.php

示例5: addOption

 /**
  * Add an option to the Select's options
  *
  * @param array|string $text       It's value or an array of values
  * @param string       $value      It's text
  * @param array        $attributes The option's attributes
  */
 public function addOption($text = null, $value = null, $attributes = array())
 {
     // Get the option's value
     $childrenKey = !is_null($value) ? $value : sizeof($this->children);
     // If we passed an options group
     if (is_array($text)) {
         $this->children[$childrenKey] = Element::create('optgroup')->label($value);
         foreach ($text as $key => $value) {
             $option = Element::create('option', $value)->setAttribute('value', $key);
             $this->children[$childrenKey]->nest($option);
         }
         // Else if it's a simple option
     } else {
         if (!isset($attributes['value'])) {
             $attributes['value'] = $value;
         }
         $this->children[$attributes['value']] = Element::create('option', $text)->setAttributes($attributes);
     }
     return $this;
 }
開發者ID:laralite,項目名稱:form,代碼行數:27,代碼來源:Select.php

示例6: placeAround

 /**
  * Wrap an item to be prepended or appended to the current field
  *
  * @param  string $item
  *
  * @return Element A wrapped item
  */
 public function placeAround($item)
 {
     return Element::create('span', $item);
 }
開發者ID:laralite,項目名稱:form,代碼行數:11,代碼來源:Nude.php

示例7: legend

 /**
  * Creates a form legend
  *
  * @param  string $legend     The text
  * @param  array  $attributes Its attributes
  *
  * @return Element             A <legend> tag
  */
 public function legend($legend, $attributes = array())
 {
     $legend = Helpers::translate($legend);
     return Element::create('legend', $legend, $attributes);
 }
開發者ID:erpio,項目名稱:Reportula,代碼行數:13,代碼來源:Elements.php

示例8: wrapValue

 /**
  * Wrap the value in a tag.
  *
  * @param string $tag The tag
  *
  * @return $this
  */
 public function wrapValue($tag)
 {
     $this->value = Element::create($tag, $this->value);
     return $this;
 }
開發者ID:anahkiasen,項目名稱:html-object,代碼行數:12,代碼來源:Tag.php

示例9: wrapField

 /**
  * Wraps all field contents with potential additional tags.
  *
  * @param  Field $field
  *
  * @return Element A wrapped field
  */
 public function wrapField($field)
 {
     if ($this->app['form.form']->isOfType('horizontal')) {
         return Element::create('div', $field)->addClass($this->fieldWidth);
     } else {
         return $field;
     }
 }
開發者ID:laralite,項目名稱:form,代碼行數:15,代碼來源:ZurbFoundation5.php

示例10: defined

<?php

defined('C5_EXECUTE') or die("Access Denied.");
$tag = \HtmlObject\Element::create('amp-youtube');
$tag->setAttribute('data-videoid', h($videoID));
$tag->setAttribute('layout', 'responsive');
$width = $vWidth ? $vWidth : '480';
$height = $vHeight ? $vHeight : '270';
$tag->setAttribute('width', h($width));
$tag->setAttribute('height', h($height));
echo $tag;
開發者ID:hissy,項目名稱:concrete5-amp,代碼行數:11,代碼來源:amp.php

示例11: testCanCreateDefaultElement

 public function testCanCreateDefaultElement()
 {
     $this->assertHTML($this->getMatcher(), Element::create()->setValue('foo'));
 }
開發者ID:Geekathon,項目名稱:reddit-clone,代碼行數:4,代碼來源:TagTest.php

示例12: createIcon

 /**
  * Render an icon
  *
  * @param array  $attributes   Its general attributes
  *
  * @return string
  */
 public function createIcon($iconType, $attributes = array(), $iconSettings = array())
 {
     // Check for empty icons
     if (!$iconType) {
         return false;
     }
     // icon settings can be overridden for a specific icon
     $tag = array_get($iconSettings, 'tag', $this->iconTag);
     $set = array_get($iconSettings, 'set', $this->iconSet);
     $prefix = array_get($iconSettings, 'prefix', $this->iconPrefix);
     return Element::create($tag, null, $attributes)->addClass("{$set} {$prefix}-{$iconType}");
 }
開發者ID:aleguisf,項目名稱:fvdev1,代碼行數:19,代碼來源:Framework.php

示例13: setLabel

 /**
  * Adds a label to the group
  *
  * @param  string $label A label
  */
 public function setLabel($label)
 {
     if (!$label instanceof Element) {
         $label = Helpers::translate($label);
         $label = Element::create('label', $label)->for($label);
     }
     $this->label = $label;
 }
開發者ID:autocar,項目名稱:former,代碼行數:13,代碼來源:Group.php

示例14: render

 /**
  * Get the evaluated string content of the ItemList.
  *
  * @param  integer $depth The depth at which the ItemList should be rendered
  *
  * @return string
  */
 public function render($depth = 0)
 {
     if (!is_int($depth)) {
         throw new Exception("The render method doesn't take any arguments anymore, you can now configure your menu via the config file.");
     }
     // Check for maximal depth
     $maxDepth = $this->getOption('max_depth');
     if ($maxDepth !== -1 and $depth > $maxDepth) {
         return false;
     }
     // Render contained items
     $contents = null;
     if (count($this->children) == 0) {
         return "";
     }
     foreach ($this->children as $item) {
         $contents .= $item->render($depth + 1);
     }
     $element = $this->getElement();
     if ($element) {
         $contents = Element::create($element, $contents, $this->attributes)->render();
     }
     return $contents;
 }
開發者ID:vespakoen,項目名稱:menu,代碼行數:31,代碼來源:ItemList.php

示例15: wrapActions

 /**
  * Wrap actions block with potential additional tags
  *
  * @param  Actions $actions
  *
  * @return string A wrapped actions block
  */
 public function wrapActions($actions)
 {
     // For horizontal forms, we wrap the actions in a div
     if ($this->app['former.form']->isOfType('horizontal')) {
         return Element::create('div', $actions)->addClass(array($this->fieldOffset, $this->fieldWidth));
     }
     return $actions;
 }
開發者ID:autocar,項目名稱:former,代碼行數:15,代碼來源:TwitterBootstrap3.php


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