IBATextFormField with default value?

85 views
Skip to first unread message

uzman

unread,
May 30, 2012, 1:32:33 PM5/30/12
to ibaf...@googlegroups.com
is it possible to create a IBATextFormField with default value?

IBATextFormField *name1 = [[IBATextFormField alloc] initWithKeyPath:@"name" title:@"Name"];
[section1 addFormField:[name1 autorelease]];
name1.textFormFieldCell.textField.text=@"Default Name";// it doesn't show the Text.
name1.textFormFieldCell.textField.placeholder=@"placeholder";// it is OK


Pulkit Singhal

unread,
May 30, 2012, 7:11:20 PM5/30/12
to ibaf...@googlegroups.com
Have a look at the fork by https://github.com/shouze/IBAForms, they have a really nice cancel button and placeholder implementation as part of their sample demo code.

Sean Woodhouse

unread,
May 30, 2012, 7:51:02 PM5/30/12
to ibaf...@googlegroups.com
uzman,

Your form fields are bond to your model using KVO. You're not seeing 'Default Name' as the value of the textField's text because it is being overwritten by the framework with the value of the 'name' property in your model. If you want to set a default value simply set the 'name' property of of your model to be that value and it'll appear in the text field. You pretty much never want to set the text value of a form field directly since it is populated buy the framework from the model. If you want to change the way the value is presented in the form field you should use an NSValueTransformer to do that.

Does that make sense?

Cheers

Sean
Reply all
Reply to author
Forward
0 new messages