Fix template engine rending attributes with multiselect configured

This commit is contained in:
Deon George 2010-02-24 22:20:26 +11:00
parent ac1d121b0d
commit a1c714bdb8
4 changed files with 12 additions and 1 deletions

View File

@ -477,6 +477,10 @@ class Attribute {
$this->readonly = true; $this->readonly = true;
} }
public function isMultiple() {
return false;
}
public function isVisible() { public function isVisible() {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);

View File

@ -85,6 +85,7 @@ class AttributeFactory {
case 'password': case 'password':
return $this->newPasswordAttribute($name,$values,$server_id,$source); return $this->newPasswordAttribute($name,$values,$server_id,$source);
case 'multiselect':
case 'select': case 'select':
return $this->newSelectionAttribute($name,$values,$server_id,$source); return $this->newSelectionAttribute($name,$values,$server_id,$source);

View File

@ -1011,6 +1011,9 @@ class PageRender extends Visitor {
$vals = $attribute->getValues(); $vals = $attribute->getValues();
$j = 0; $j = 0;
if (! $vals && ! is_array($vals = $attribute->getDefault()))
$vals = array($attribute->getDefault());
if (($attribute->getSize() > 0) && ($attribute->getSize() < $attribute->getOptionCount())) { if (($attribute->getSize() > 0) && ($attribute->getSize() < $attribute->getOptionCount())) {
printf('<select name="new_values[%s][]" size="%s" multiple>', printf('<select name="new_values[%s][]" size="%s" multiple>',
@ -1058,7 +1061,7 @@ class PageRender extends Visitor {
foreach ($vals as $val) foreach ($vals as $val)
if (! isset($selected[$val])) if (! isset($selected[$val]))
printf('<tr><td><input type="checkbox" id="%s" name="new_values[%s][]" value="%s" %s%s checked/></td><td><span style="white-space: nowrap;">&nbsp;%s</span></td></tr>', printf('<tr><td><input type="checkbox" id="new_values_%s_%s" name="new_values[%s][]" value="%s" %s%s checked/></td><td><span style="white-space: nowrap;">&nbsp;%s</span></td></tr>',
htmlspecialchars($attribute->getName()),$j++, htmlspecialchars($attribute->getName()),$j++,
htmlspecialchars($attribute->getName()),$val, htmlspecialchars($attribute->getName()),$val,
$attribute->needJS('focus') ? sprintf('onFocus="focus_%s(this);" ',$attribute->getName()) : '', $attribute->needJS('focus') ? sprintf('onFocus="focus_%s(this);" ',$attribute->getName()) : '',

View File

@ -2042,6 +2042,9 @@ function fillRec(id,value) {
protected function drawValueAttribute($attribute,$i) { protected function drawValueAttribute($attribute,$i) {
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__);
if ($attribute->isMultiple() && $i > 0)
return;
$val = $attribute->getValue($i); $val = $attribute->getValue($i);
if ($attribute->isVisible()) { if ($attribute->isVisible()) {