| Index
» Projekty
» phpMyEdit
» Fórum
» Display a MySql-Enumeration as Radio Buttons? |
 |
rolloderwikinger
Založený: 16.06.2006
Príspevky: 6
Zaslal: 2006-06-16 12:58
Návrat hore
Odpovedať s citátom
|
hi, I have a MySQL field called 'gender' which is an enumeration of values 'male' and 'female'. Is there a chance to get these values displayed as radio buttons (two of them with a male and female label) when adding a new record? So far I always get a drop-down box with the two values. Thanks and regards Roland
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2006-06-16 13:14
Návrat hore
Odpovedať s citátom
|
not by standard means.
you can hack the class
or use 'php' option http://opensource.platon.sk/projects/bug_view_advanced_page.php?f_bug_id=393
(let me know if you find it usefull) (which is just easier way of hacking the class)
|
rolloderwikinger
Založený: 16.06.2006
Príspevky: 6
Zaslal: 2006-06-16 15:46
Návrat hore
Odpovedať s citátom
|
Hi, wouldn't it be easyer to modify the code like:
...
if ($this->fdd[$k]['select'] == 'R') {
echo $this->htmlRadio($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name,
$vals, $selected, $multiple, $readonly, $strip_tags, $escape);
}
else {
echo $this->htmlSelect($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name,
$vals, $selected, $multiple, $readonly, $strip_tags, $escape);
}
} elseif (isset ($this->fdd[$k]['textarea'])) {
and then add a function
function htmlRadio($name, $css, $kv_array, $selected = null, /* ...) {{{ */
/* booleans: */ $multiple = false, $readonly = false, $strip_tags = false, $escape = true, $js = NULL)
{
$ret = '<input type=radio class="'.htmlspecialchars
...
and may be even support checkboxes this way by placing something like
if ($multiple) { $typeword='checkbox'; }
else $typeword='radio'
$ret = '<input type=' $typeword ' class="'.htmlspecialchars
Above codesniplet would introduce a new option for the select parameter of a field R which only is relevant if the field has values.
What do you think?
/Roland
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2006-06-16 17:21
Návrat hore
Odpovedať s citátom
|
i would be a lot more happy to reduce the size of core class, putting options like this outside of core class. but this would require a lot of code rewriting and moving around (without a special effect).
so to sum up, can you use the php option. we will make a repository for these files.[/img]
|
rolloderwikinger
Založený: 16.06.2006
Príspevky: 6
Zaslal: 2006-06-16 19:02
Návrat hore
Odpovedať s citátom
|
Hi,
Yes, the include mechanism
...
} elseif ($this->col_has_php($k)) {
echo include($this->fdd[$k]['php']);
} else {...
certainly works as I have access to all variables also found in the calling "function".
I'll go for this solution.
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|