+2005-09-27 Helge Hess <helge.hess@skyrix.com>
+
+ * DynamicElements/WOPopUpButton.m: fixed a bug in the 'selection' which
+ occurred when the element is being used with the 'value' binding
+ (returned the last item instead of nil for 'noSelectionString')
+ (v4.5.202)
+
2005-09-18 Helge Hess <helge.hess@opengroupware.org>
* GNUmakefile.preamble: added missing linking path to NGMail (required
@implementation WOPopUpButton
static NSNumber *yesNum = nil;
+static BOOL debugPopUp = NO;
+ (int)version {
return [super version] + 0 /* v2 */;
return;
formValue = [_rq formValueForKey:OWFormElementName(self, _ctx)];
-#if 0
- [self logWithFormat:@"%@: value=%@ ..", [self elementID], formValue];
-#endif
-
+ if (debugPopUp) {
+ [self logWithFormat:@"%@ / %@: value=%@ ..", OWFormElementName(self, _ctx),
+ [_ctx elementID], formValue];
+ }
+
if (formValue == nil) {
/* nothing changed, or not in submitted form */
+ if (debugPopUp) [self logWithFormat:@"found no form value!"];
return;
}
if (self->value != nil) {
/* has a value binding, walk list to find object */
unsigned i, toGo;
-
+
+ if (debugPopUp) [self logWithFormat:@"scan value: %@", self->value];
+
for (i = 0, toGo = [objects count]; i < toGo; i++) {
NSString *cv;
if ([cv isEqualToString:formValue])
break;
+
+ // important, reset object otherwise the last item will be preselected!
+ object = nil;
}
}
else if (![formValue isEqualToString:WONoSelectionString]) {
if ([self->selection isValueSettable]) {
NSArray *sel;
- if (object) {
+ if (object != nil) {
sel = [object retain];
}
else /* nil item selected */