本文整理汇总了PHP中Select::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::setValue方法的具体用法?PHP Select::setValue怎么用?PHP Select::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Select
的用法示例。
在下文中一共展示了Select::setValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* @covers Xoops\Form\Select::render
* @covers Xoops\Form\Select::renderOption
* @covers Xoops\Form\Element::themeDecorateElement
*/
public function testRender()
{
$this->object->addOptionArray(array('opt_key' => 'opt_name', 'opt_just_key' => null));
$this->object->setValue('opt_key');
$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->addOptionGroup('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: createSelect
private function createSelect($name, $options)
{
$select = new Select();
$select->setLanguage($this->language);
$select->push('name', $this->getName() . '[' . $name . ']');
if ($this->value && $this->value[$name]) {
$select->setValue($this->value[$name]);
}
$this->proxyPush($select);
$this->buildOptions($select, $options);
return $select;
}
示例3: isset
<head>
<meta charset="utf-8">
<title>Form Class</title>
</head>
<body>
<form class="" action="task13.php" method="post">
<input type="text" name="name" value="<?php
echo isset($_POST['name']) ? $_POST['name'] : '';
?>
">
<input type="text" name="username" value="<?php
echo isset($_POST['username']) ? $_POST['username'] : '';
?>
">
<input type="text" name="email" value="<?php
echo isset($_POST['email']) ? $_POST['email'] : '';
?>
">
<?php
$select = new Select();
$select->setName('browser');
if (isset($browserTypes)) {
$select->setValue($browserTypes);
$select->makeSelect();
}
?>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
示例4: Select
$selectBrowser = new Select();
$selectBrowser->setName('browser');
echo '<p>Work Access</p>';
if (isset($browserTypes)) {
$selectBrowser->setValue($browserTypes);
$selectBrowser->makeSelect();
unset($selectBrowser);
}
echo '<p>Connection Speed</p>';
$selectSpeed = new Select();
$selectSpeed->setName('speeds');
if (isset($speeds)) {
$selectSpeed->setValue($speeds);
$selectSpeed->makeSelect();
unset($selectSpeed);
}
echo '<p>Operating System</p>';
$selectOs = new Select();
$selectOs->setName('os');
if (isset($os)) {
$selectOs->setValue($os);
$selectOs->makeSelect();
unset($selectOs);
}
?>
<input type="submit" name="submit" value="Submit">
</form>
</div>
</body>
</html>
示例5: Select
<p>
Username:
<input type="text" name="username" size="60" />
</p>
<p>
Email:
<input type="text" name="email" size="60" />
</p>
<p>
Browser:
<?php
//Instantiate object
$browser = new Select();
//Set properties
$browser->setName('browser');
$browser->setValue($browsers);
//The object has the data it needs from the preceding commands.
//Tell it to make the select field.
$browser->makeSelect();
?>
</p>
<p>
<input type="submit" name="submit" value="Go" />
</p>
</form>
<?php
//If form submitted, process input.
} else {
//Retrieve user responses.
$name = $_POST['name'];
$username = $_POST['username'];