本文整理汇总了PHP中Dropdown::addOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Dropdown::addOption方法的具体用法?PHP Dropdown::addOption怎么用?PHP Dropdown::addOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dropdown
的用法示例。
在下文中一共展示了Dropdown::addOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToStringWithLink
/**
* @covers Dropdown::toString
*/
public function testToStringWithLink()
{
$optionValue = array("Fruition Brazil");
$this->drop->setValue($optionValue);
$this->drop = $this->drop->addOption("brazilia", "Fruition Brazil");
$this->drop->setReadonlyLink(new \Link("fruitionsciences.com", "Fruition Sciences"));
$actual = $this->drop->toString();
$excepted = '<option value="Fruition Brazil">brazilia</option>';
$this->assertEquals($excepted, $actual);
}
示例2: editObject
protected function editObject(Model $oObject, $template = '')
{
$form = new Form();
if ($_POST) {
$this->save($oObject);
$this->assign('updates', $this->updates);
$this->assign('errors', $form->getErrors());
}
$fields = $oObject->getTableStructure();
$isSetting = false;
if ($oObject instanceof Setting) {
$isSetting = true;
$this->readOnlyFields[] = 'name';
$this->readOnlyFields[] = 'info';
}
foreach ($fields as $fieldName => $field) {
if ($isSetting && $fieldName == 'value') {
$settingType = str_replace('BOOLEAN', 'tinyint(1)', $settingType);
$settingType = str_replace('INTEGER', 'VARCHAR', $settingType);
$settingType = str_replace('FLOAT', 'VARCHAR', $settingType);
$field['Type'] = strtolower($settingType);
}
if (!is_numeric($fieldName) && !in_array($fieldName, $this->hideFields)) {
$value = $oObject->{$fieldName};
$fieldTable = convertDbFieldToTable($fieldName);
if ($fieldName != 'nefub_id' && substr($fieldName, -3, 3) == '_id') {
// left join
if (substr($fieldName, -9, 9) == '_nefub_id') {
// left join on nefub_id
$split = explode('_nefub_id', $fieldName);
$valueField = 'nefub_id';
} else {
// left join on id
$split = explode('_id', $fieldName);
$valueField = 'id';
}
$fieldTable = convertDbFieldToTable($fieldName);
if ($fieldTable == 'Game') {
$input = new GameDropdown($fieldName, $value, $oObject->getGame());
} elseif ($fieldTable == 'Team') {
$input = new TeamDropdown($fieldName, $value);
} elseif ($fieldTable == 'Location') {
$input = new LocationDropdown($fieldName, $value);
} else {
$input = new ModelDropdown($fieldName, $value, $fieldTable, $valueField);
}
} else {
if (substr(strtolower($field['Type']), 0, 4) == 'enum') {
$input = new EnumDropdown($fieldName, $value, $field['Type']);
if ($isSetting) {
$settingType = $value;
}
} else {
if ($fieldName != 'nefub_id' && substr($field['Type'], 0, 3) == 'int') {
$length = substr($field['Type'], 4, strlen($field['Type']) - 2);
if ($length >= 5) {
$input = new InputText($fieldName, $value);
$input->addValidator(new IntegerValidator(true, 0, pow(10, $length)));
} else {
$input = new NumericDropdown($fieldName, $value, 0, pow(10, $length) - 1);
}
} else {
if ($fieldName == 'Period') {
$values = array(1 => 1, 2 => 2, 3 => 3);
$input = new RadioButton($fieldName, $values, $value);
} else {
if ($field['Type'] == 'int(1)' || $field['Type'] == 'tinyint(1)') {
$input = new RadioBoolean($fieldName, $value);
} else {
if ($field['Type'] == 'time' && $oObject->getTable() != 'GameAction') {
$input = new Dropdown($fieldName, $value);
for ($i = 0; $i < 24; $i++) {
$hour = $i;
if ($hour < 10) {
$hour = '0' . $hour;
}
for ($j = 0; $j < 60; $j += 10) {
$minute = $j;
if ($minute < 10) {
$minute = '0' . $minute;
}
$time = $hour . ':' . $minute;
$input->addOption($time, $time . ':00');
}
}
} elseif ($field['Type'] == 'text') {
$input = new TextArea($fieldName, $value);
} else {
$input = new InputText($fieldName, $value);
}
}
}
}
}
}
// read-only fields
if (in_array($fieldName, $this->readOnlyFields)) {
$input->setExtraAttribute('disabled', 'disabled');
}
if ($field['Null'] == 'NO') {
//.........这里部分代码省略.........
示例3: getPMDropdown
private function getPMDropdown()
{
$selectPM = new Dropdown("_" . $this->getName() . "_pm");
$selectPM->set("id", "_" . $this->getName() . "_pm");
$selectPM->addOption("am", "am")->addOption("pm", "pm");
$selectPM->set("class", "dateBox");
$selectPM->set("onchange", "updateHiddenTimeField('" . $this->getName() . "')");
return $selectPM;
}