Open realenginerd opened 8 years ago
Further observation: seems as though Placeholder and Default Value doesn't work well together; I can only get one or the other. I can select the Placeholder with no problems if there is no Default Value specified. However, if I cannot specify a Default Value, the form does not get populated correctly.
On the other hand, if a Default Value is specified, the opposite problem occurs: the form shows up correctly -- default value is selected -- but I cannot select the Placeholder.
Am I holding this wrong? Is there a way to make this work? Please advise. Thanks in advance!
I have solved this problem by adding
if ([value unsignedIntegerValue] == NSNotFound) return nil;
to 'value' getter:
- (id)value
{
if (FXFormCanGetValueForKey(self.form, self.key))
{
id value = [(NSObject *)self.form valueForKey:self.key];
if (value && self.options)
{
if ([self isIndexedType])
{
if ([value unsignedIntegerValue] == NSNotFound) return nil;
if ([value unsignedIntegerValue] >= [self.options count]) value = nil;
}
else if (![self isCollectionType] && ![self.type isEqualToString:FXFormFieldTypeBitfield])
{
//TODO: should we validate collection types too, or is that overkill?
if (![self.options containsObject:value]) value = nil;
}
}
if (!value && self.defaultValue)
{
self.value = value = self.defaultValue;
}
return value;
}
return self.defaultValue;
}
I have a form where one of the fields is a "multiple choice":
The form appears correctly. "No key" appears at the top of the list, and is selected (marked with a check mark) if
key
isnil
. When I click on a different key, it gets assigned tokey
correctly, and the check mark migrates accordingly.When I try to click back on "No key", however, nothing happens. The (placeholder) cell is briefly highlighted, but the check mark does not migrate. The 'key' field still contains the old value, and does not get reset to
nil
. What should I do to get it to work this way? Is this supported in FXForms?