本文整理汇总了PHP中Text::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::render方法的具体用法?PHP Text::render怎么用?PHP Text::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::render方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* @covers Xoops\Form\Text::render
*/
public function testRender()
{
$value = $this->object->render();
$this->assertTrue(is_string($value));
$this->assertTrue(false !== strpos($value, '<input'));
$this->assertTrue(false !== strpos($value, 'type="text"'));
$this->assertTrue(false !== strpos($value, 'name="name"'));
$this->assertTrue(false !== strpos($value, 'size="10"'));
$this->assertTrue(false !== strpos($value, 'maxlength="20"'));
$this->assertTrue(false !== strpos($value, 'placeholder="placeholder"'));
$this->assertTrue(false !== strpos($value, 'title="Caption"'));
$this->assertTrue(false !== strpos($value, 'id="name"'));
$this->assertTrue(false !== strpos($value, 'value="value"'));
}
示例2: render
public function render()
{
$this->setValue(null);
// ensure the value is not displayed
$this->set('type', 'password');
return parent::render();
}
示例3: testPlacementAppend
public function testPlacementAppend()
{
$decorator = new Text('foo');
$decorator->setOption('placement', 'append');
$expected = 'barfoo';
$actual = $decorator->render('bar');
$this->assertSame($expected, $actual);
}
示例4: render
public function render(array $attributes = [], array $viewData = [])
{
$this->options = array_merge($this->getOptions(), $attributes);
$value = request($this->name, $this->getOption('value'));
if ($this->isChecked($value)) {
$this->options['checked'] = 'checked';
}
return parent::render($attributes, $viewData);
}
示例5: render
public function render(array $attributes = [], array $viewData = [])
{
$this->options = array_merge($this->options, $attributes);
// Since the hidden type does not have a label,
// we can use its value to pass the value of the hidden
if (strlen($this->getOption('value')) === 0) {
$this->options['value'] = $this->getLabel();
$this->value = $this->getLabel();
}
return parent::render($attributes, $viewData);
}
示例6: render
/**
* render
*
* @return string
*/
public function render()
{
$xoops = \Xoops::getInstance();
if ($xoops->theme()) {
$xoops->theme()->addScript('include/color-picker.js');
} else {
echo '<script type="text/javascript" src="' . \XoopsBaseConfig::get('url') . '/include/color-picker.js"></script>';
}
$this->setExtra(' style="background-color:' . $this->getValue() . ';"');
return parent::render() . "<button class='btn' type='button' onclick=\"return TCP.popup('" . \XoopsBaseConfig::get('url') . "/include/',document.getElementById('" . $this->getName() . "'));\"> ... </button>";
}
示例7: render
/**
* render
*
* @return string
*/
public function render()
{
$xoops = \Xoops::getInstance();
if ($xoops->theme()) {
$xoops->theme()->addScript('include/color-picker.js');
} else {
echo '<script type="text/javascript" src="' . $xoops->url('/include/color-picker.js') . '"></script>';
}
$temp = $this->get('value', '');
if (!empty($temp)) {
$this->set('style', 'background-color:' . $temp . ';');
}
return parent::render() . "<button class='btn' type='button' onclick=\"return TCP.popup('" . $xoops->url('/include/') . "',document.getElementById('" . $this->getName() . "'));\"> ... </button>";
}
示例8: valid
public static function valid($rules, $data)
{
static::$errors = [];
static::triggerOnce('init');
self::$data = $data = (array) $data;
foreach ((array) $rules as $field_name => $rule) {
$current = isset($data[$field_name]) ? $data[$field_name] : null;
if (is_callable($rule)) {
static::$errors[$field_name] = call_user_func($rule, $current);
continue;
} elseif (is_string($rule)) {
$current_rules = array_flip(preg_split('/\\s*\\|\\s*/', $rule));
} else {
$current_rules = (array) $rule;
}
static::$errors[$field_name] = true;
foreach ($current_rules as $method => $message) {
$meth_name = strtok($method, ':');
$opts = strtok(':') ?: '';
$opts = $opts ? json_decode("[{$opts}]") : [];
$meth_opts = $opts ? array_merge([$current], $opts) : [$current];
if (static::$errors[$field_name] !== true) {
continue 2;
}
if (empty(static::$methods[$meth_name])) {
static::$errors[$field_name] = true;
} else {
if (call_user_func_array(static::$methods[$meth_name]->validate, $meth_opts)) {
static::$errors[$field_name] = true;
} else {
$arg = [];
foreach ($meth_opts as $key => $value) {
$arg["arg_{$key}"] = $value;
}
static::$errors[$field_name] = Text::render(static::$methods[$meth_name]->message, $arg);
}
}
}
}
self::$data = [];
// Clean non-errors
static::$errors = array_filter(static::$errors, function ($v) {
return $v !== true;
});
return empty(static::$errors);
}
示例9: testInput
public function testInput()
{
$text = new Text(['value' => "Valor", 'id' => 'id']);
$text->setPlaceholder("Placeholder");
$this->assertEquals($text->render(), '<div><input value="Valor" id="id" type="text" placeholder="Placeholder" /></div>');
}
示例10: testWords
/**
* @dataProvider dataProviderTestWords
*/
public function testWords($in, $out)
{
$this->assertSame($out, $this->me->render(new \Inml\Text($in)));
}
示例11: translate
public static function translate($text, $params = null)
{
$result = static::get(static::$current_lang . '.' . strtolower($text), $text);
return $params ? Text::render($result) : $result;
}