本文整理汇总了PHP中Select::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::render方法的具体用法?PHP Select::render怎么用?PHP Select::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Select
的用法示例。
在下文中一共展示了Select::render方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* @covers Xoops\Form\Select::render
* @todo Implement testRender().
*/
public function testRender()
{
$this->object->addOptionArray(array('opt_key' => 'opt_name', 'opt_just_key' => null));
$value = $this->object->render();
$this->assertTrue(is_string($value));
$this->assertTrue(false !== strpos($value, '<select'));
$this->assertTrue(false !== strpos($value, 'name="name"'));
$this->assertTrue(false !== strpos($value, 'size="1"'));
$this->assertTrue(false !== strpos($value, 'title="Caption"'));
$this->assertTrue(false !== strpos($value, 'id="name"'));
$this->assertTrue(false !== strpos($value, '<option'));
$this->assertTrue(false !== strpos($value, 'value="opt_key"'));
$this->assertTrue(false !== strpos($value, '>opt_name</option>'));
$this->assertTrue(false !== strpos($value, 'value="opt_just_key"'));
$this->assertTrue(false !== strpos($value, '>opt_just_key</option>'));
$this->object = new Select('Caption', 'name', 'value');
// reset object
$groups = array('grp_key' => 'grp_name', 'grp_key1' => 'grp_name1');
$this->object->addOptgroup('opt_grp_name', $groups);
$value = $this->object->render();
$this->assertTrue(is_string($value));
$this->assertTrue(false !== strpos($value, '<select'));
$this->assertTrue(false !== strpos($value, 'name="name"'));
$this->assertTrue(false !== strpos($value, 'size="1"'));
$this->assertTrue(false !== strpos($value, 'title="Caption"'));
$this->assertTrue(false !== strpos($value, 'id="name"'));
$this->assertTrue(false !== strpos($value, '<optgroup'));
$this->assertTrue(false !== strpos($value, 'label="opt_grp_name"'));
$this->assertTrue(false !== strpos($value, '<option'));
$this->assertTrue(false !== strpos($value, 'value="grp_key"'));
$this->assertTrue(false !== strpos($value, '>grp_name</option>'));
$this->assertTrue(false !== strpos($value, 'value="grp_key1"'));
$this->assertTrue(false !== strpos($value, '>grp_name1</option>'));
}
示例2: render
public function render()
{
$name = $this->get('name');
if (substr($name, -2) !== '[]') {
$this->set('name', $name . '[]');
}
return parent::render();
}
示例3: it_renders_with_options_the_full_html
/** @test */
public function it_renders_with_options_the_full_html()
{
$field = new Select('test', 'Test', ['values' => ['miro' => 'test']]);
$field->render();
$options = $field->options();
$this->assertCount(1, $options);
$this->assertInstanceOf(Option::class, $options[0]);
}
示例4: render
public function render()
{
$options = [];
foreach (range($this->min, $this->max) as $year) {
$options[$year] = $year;
}
$this->setOptions($options);
return parent::render();
}
示例5: render
public function render()
{
// check if we have options
if ($this->options == null) {
// if we don't have options, we set only 'yes' and 'no'
$this->setOptions($this->getYesNo());
} else {
// if options is set, it means that a options['select'] is given
// we combine it with yes/no
$this->setOptions($this->options += $this->getYesNo());
}
return parent::render();
}
示例6: render
public function render()
{
$args = array();
if (!empty($this->attributes['args'])) {
$args = $this->attributes['args'];
}
$terms = get_terms($this->attributes['taxonomies'], $args);
$options = array();
if (!empty($this->attributes['options'])) {
$options = $this->attributes['options'];
}
foreach ($terms as $term) {
$options[$term->term_id] = $term->name;
}
$this->attributes['options'] = $options;
parent::render();
}
示例7: render
/**
* Representação textual da query
*
* @return string
* */
public function render()
{
return $this->_select->render();
}
示例8: render
/**
* @param string $name The element name
* @param string $value The time displayed in this widget
* @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
* @param array $errors An array of errors for the field
*
* @return string An HTML tag string
*
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(), $errors = array())
{
// convert value to an array
$default = array('hour' => null, 'minute' => null, 'second' => null);
if (is_array($value)) {
$value = array_merge($default, $value);
} else {
$value = ctype_digit($value) ? (int) $value : strtotime($value);
if (false === $value) {
$value = $default;
} else {
// int cast required to get rid of leading zeros
$value = array('hour' => (int) date('H', $value), 'minute' => (int) date('i', $value), 'second' => (int) date('s', $value));
}
}
$time = array();
$emptyValues = $this->getOption('empty_values');
// hours
$widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours')), array_merge($this->attributes, $attributes));
$time['%hour%'] = $widget->render($name . '[hour]', $value['hour']);
// minutes
$widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes')), array_merge($this->attributes, $attributes));
$time['%minute%'] = $widget->render($name . '[minute]', $value['minute']);
if ($this->getOption('with_seconds')) {
// seconds
$widget = new Select(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds')), array_merge($this->attributes, $attributes));
$time['%second%'] = $widget->render($name . '[second]', $value['second']);
}
return strtr($this->getOption('with_seconds') ? $this->getOption('format') : $this->getOption('format_without_seconds'), $time);
}
示例9: prepareSmarty
/**
* Display this class
*/
private function prepareSmarty()
{
$this->smarty = new Template();
$this->smarty->assign('heading', $this->file->filename);
$this->smarty->assign('title', $this->file->filename);
$this->smarty->assign('file', $this->file);
$this->smarty->requireResource('file');
$select = new Select('permission', '', FilePermissions::getAll());
$select->selected_value = $this->file->permission;
$this->smarty->assign('permission', $select->render());
}
示例10: test__construct
/**
* @covers Xoops\Form\Select::__construct
* @covers Xoops\Form\Select::render
* @covers Xoops\Form\Select::renderValidationJS
*/
public function test__construct()
{
$oldWay = new Select('mycaption', 'myname', 'opt1');
$oldWay->addOption('opt1', 'optname1');
$oldWay->addOption('opt2', 'optname2');
$newWay = new Select(['caption' => 'mycaption', 'name' => 'myname', 'value' => 'opt1', 'option' => ['opt1' => 'optname1', 'opt2' => 'optname2']]);
$this->assertEquals($oldWay->render(), $newWay->render());
$this->assertEquals($oldWay->renderValidationJS(), $newWay->renderValidationJS());
}
示例11: testInput
public function testInput()
{
$select = new Select(['name' => "name"]);
$select->addOptions([1 => "Valor", 2 => "Valor 2"]);
$this->assertEquals($select->render(), '<div><select name="name"><option value="1">Valor</option><option value="2">Valor 2</option></select></div>');
}
示例12: render
public function render()
{
$files = $this->getFiles();
// set "images" hardcoded to identify the select options and append the Name
parent::setID('images_' . $this->getNameWithoutBrackets());
if (empty($files)) {
$this->html = 'There are no images in "' . $this->getDirectory() . '" to select. Please upload some.';
} else {
$this->setOptions($files);
// @todo first image is not displayed... display it.
// Watch out!
// the div images/preview must be present in the dom, before you assign js function to it via $('#image')
$javascript = '<script type="text/javascript">
$(document).ready(function () {
$("#images_' . $this->getNameWithoutBrackets() . '").change(function () {
var src = $("option:selected", this).val();
$("#imagePreview_' . $this->getNameWithoutBrackets() . '").html(
src ? "<img src=\'" + src + "\'>" : ""
);
});
});
</script>';
$html = parent::render() . CR . '<div id="imagePreview_' . $this->getNameWithoutBrackets() . '"></div>';
$this->html = $html . $javascript;
}
return $this->html;
}
示例13: renderYearWidget
/**
* @param string $name
* @param string $value
* @param array $options
* @param array $attributes
* @return string rendered widget
*/
protected function renderYearWidget($name, $value, $options, $attributes)
{
$widget = new Select($options, $attributes);
return $widget->render($name, $value);
}
示例14: get_select
/**
* Select getter Function
* @see skip_select()
* @ignore
*/
function get_select($name, $elements, $label = FALSE, $args = array(), $return = 'html')
{
$select = new Select($name, $label, $args);
if (count($elements) > 0) {
if (is_array($elements)) {
foreach ($elements as $element) {
$select->add_element($element);
}
} else {
$values = explode(',', $elements);
foreach ($values as $value) {
$select->add_element(array('value' => $value));
}
}
}
return $select->render();
}