xmartlabs / XLForm

XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.
MIT License
5.77k stars 953 forks source link

DatePicker isn't setting default/"initial" value to textfield #744

Open royherma opened 8 years ago

royherma commented 8 years ago

The user needs to scroll up or down and back to the original value in order for it to be set. Should have the value set on popup/display of the UIDatePicker/PickerView (or at least an option to turn on this functionality)

mats-claassen commented 8 years ago

I remember to have seen this but I am not seeing it anymore. In which version have you seen this bug?

And how exactly are you setting up this DatePicker?

royherma commented 8 years ago

Version 3.1.0 . Here is an example of my usage:

XLFormRowDescriptor *row;

    row = [XLFormRowDescriptor formRowDescriptorWithTag:kStartDateCell
                                                rowType:XLFormRowDescriptorTypeDate];
    row.title = NSLocalizedString(@"Start Date", nil);
    row.value = self.ooo.startDate.isValid ? self.ooo.startDate : nil;
    row.required = YES;
    row.requireMsg = @"You must specify a start date";
    row.valueTransformer = K2FormDatePickerFormatter.class;
    [K2FormViewController setTitleFontForRow:row forKey:@"textLabel.font"];
    [K2FormViewController setTitleTextColorForRow:row forKey:@"textLabel.textColor"];
    [K2FormViewController setFontForRow:row forKey:@"detailTextLabel.font"];
    [K2FormViewController setTextColorForRow:row forKey:@"detailTextLabel.textColor"];
    [row.cellConfig setObject:[UIColor whiteColor] forKey:@"datePicker.backgroundColor"];
    [row.cellConfig setObject:[NSDate date] forKey:@"minimumDate"];
mats-claassen commented 8 years ago

Tried your code and it works perfectly for me. Check out if it works for you with master branch.

(P.S. the only thing I commented out was the setting of fonts and text colors)