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