本文整理汇总了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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
示例11: testCanCreateDefaultElement
public function testCanCreateDefaultElement()
{
$this->assertHTML($this->getMatcher(), Element::create()->setValue('foo'));
}
示例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}");
}
示例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;
}
示例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;
}
示例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;
}