Fixed: setting CPNullPlaceholderBindingOption in binding was setting the value

This commit fix a bug where declaring the binding option CPNullPlaceholderBindingOption was actually setting the
actual value of a text field instead of just its placeholder. This commit adds a test to determine if the binding source
implements setPlaceholderString:. In that case, we let the value to be nil.
This commit is contained in:
Antoine Mercadal
2013-04-01 12:47:00 -07:00
parent 6d0caacdeb
commit 59d1da77c2
+5 -1
View File
@@ -257,7 +257,11 @@ var CPBindingOperationAnd = 0,
if (valueTransformer)
aValue = [valueTransformer transformedValue:aValue];
if (aValue === undefined || aValue === nil || aValue === [CPNull null])
// If the value is nil AND the source doesn't respond to setPlaceholderString: then
// we set the value to the placeholder. Otherwise, we do not want to short cut the process
// of setting the placeholder that is based on the fact that the value is nil.
if ((aValue === undefined || aValue === nil || aValue === [CPNull null])
&& ![_source respondsToSelector:@selector(setPlaceholderString:)])
aValue = [options objectForKey:CPNullPlaceholderBindingOption] || nil;
return aValue;