nicklockwood / fxforms Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED]
License: Other
[DEPRECATED]
License: Other
Hi,
Is there a way to programmatically update the value/placeholder of a field from a customFormController ?
When the FXFormTextViewCell is resized due to multiple lines input, the tableview's other cells below the textViewCell does not update their position properly. This issue is evident when you push to the subForm and return to the parent form.
Hey there,
so i'll start simple, something visual is worth a thousand words:
Now i'll explain a bit what we can see in that gif.
I have a two properties, one NSString
and one NSNumber
. The first one is shown as a label not editable and the second is a UISliderCell that have action on the first one.
Now the code is fairly simple:
@interface sizeForm : NSObject <FXForm>
@property (nonatomic, retain) NSString *maxStorageSize;
@property (nonatomic, retain) NSNumber *limitStorageSize;
@end
- (void)setLimitStorageSize:(NSNumber *)limitStorageSize
{
if (_limitStorageSize == limitStorageSize || [_limitStorageSize isEqualToNumber:limitStorageSize])
return ;
ReleaseAndNil(_limitStorageSize);
_limitStorageSize = [limitStorageSize retain];
if (!_limitStorageSize)
return ;
[[settingsManager instance] save:_limitStorageSize forKey:kMaxSize];
self.maxStorageSize = [_formatter stringFromNumberOfBits:_limitStorageSize];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadFxForm" object:self userInfo:@{@"form" : self}];
}
Now you can see that the maxStorageSize (NSString) is being edited by the NSNumber property setter. The question then was, how to update the label, more specifically how to tell the form to refresh the cell / label.
Well what i thought, is to tell the formViewController to update / reload the tableview through a notification (that last line).
Which for now simple call this:
- (void)handleNotification:(NSNotification*)note
{
NSLog(@"Got notified: %@", note);
[_formTableView reloadData];
}
Now as you can see, it works fine for a while, but then when you release the slider and try to play with it again it crash automatically.
I think there is something with the cells being reloaded and the field being destroyed but i lack some informations to fix this. (maybe dispatch to a thread or using synchronized ?)
here, i'll give you as much informations as i can on the crash:
backtrace
* thread #1: tid = 0x4f9204, 0x026840b2 libobjc.A.dylib`objc_msgSend + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20b8a8ac)
frame #0: 0x026840b2 libobjc.A.dylib`objc_msgSend + 14
* frame #1: 0x0007d4f8 -ios-app`-[FXFormSliderCell valueChanged](self=0x0b8a0190, _cmd=0x000c00db) + 264 at FXForms.m:2227
frame #2: 0x02686880 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 77
frame #3: 0x011b23b9 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 108
frame #4: 0x011b2345 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
frame #5: 0x012b3bd1 UIKit`-[UIControl sendAction:to:forEvent:] + 66
frame #6: 0x012b3fc6 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 577
frame #7: 0x01364b42 UIKit`-[UISlider beginTrackingWithTouch:withEvent:] + 1051
frame #8: 0x012b2c79 UIKit`-[UIControl touchesBegan:withEvent:] + 106
frame #9: 0x015482e3 UIKit`_UIGestureRecognizerUpdate + 7166
frame #10: 0x011f1a5a UIKit`-[UIWindow _sendGesturesForEvent:] + 1291
frame #11: 0x011f2971 UIKit`-[UIWindow sendEvent:] + 1021
frame #12: 0x011c45f2 UIKit`-[UIApplication sendEvent:] + 242
frame #13: 0x011ae353 UIKit`_UIApplicationHandleEventQueue + 11455
frame #14: 0x0287e77f CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #15: 0x0287e10b CoreFoundation`__CFRunLoopDoSources0 + 235
frame #16: 0x0289b1ae CoreFoundation`__CFRunLoopRun + 910
frame #17: 0x0289a9d3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #18: 0x0289a7eb CoreFoundation`CFRunLoopRunInMode + 123
frame #19: 0x041695ee GraphicsServices`GSEventRunModal + 192
frame #20: 0x0416942b GraphicsServices`GSEventRun + 104
frame #21: 0x011b0f9b UIKit`UIApplicationMain + 1225
frame #22: 0x0001b549 `main(argc=1, argv=0xbfffe8b8) + 169 at main.m:29
If i can be of any help, let me know.
Once again great work !
Hi, I've tried doing this in the fields method for a specific field:
@"textLabel.textAlignment":[NSNumber numberWithInteger:NSTextAlignmentCenter]
But it doesn't work unfortunately. Is there a way this can work?
I need to define the fields without using class properties because I create dynamically the fields to display reading them from the database.
So I can see correctly all the fields in the table but I can't get their entered value on submit.
MyForm *form = cell.field.form;
If I iterate all form.fields items I see only:
{
key = field1;
title = Field1;
type = text;
}
{
key = field2;
title = Field2;
type = text;
}
[...]
How can I get the values?
Thank you
I love this library so far, but can't figure out how to properly access the values in the form from the view controller. I'm trying to access them when a rightbarbuttonitem is clicked, but keep getting (null) - see below.
I must be missing something really obvious. A nudge in the right direction would be highly appreciated.
FXForm View controller:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Add the right bar button item
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(addProvider)];
self.navigationItem.rightBarButtonItem = saveButton;
}
- (void)addProvider
{
ManualEntryProviderForm *mepf = self.formController.form;
NSLog(@"Address1: %@", mepf.address1); // Shows Address1: (null) in console
}
View controller that displays the FXForm View controller:
- (void)clickProviderNotFound {
ManualEntryProviderViewController *fvc = [[ManualEntryProviderViewController alloc] init];
fvc.formController.form = [[ManualEntryProviderForm alloc] init];
[self.navigationController pushViewController:fvc animated:YES];
}
Thank you for this great great library it really makes building forms much easier.
Im having a problem with changing a field's options based on the user input in another field. Lets assume I have a list of 3 products: Juice, water, coffee. if the user selects juice or water then he/she can select multiple options for these products at once. If the selected product is however coffee then only one option can be selected (See code below).
I have no idea how to get the select product value and change the options based on that using FXForms. In the documentation you mention KVO and custom setter, but since Im new to IOS development I find it hard to understand without some examples, .
I hope you can give an example on how to intercept input values and update fields based on input :).
typedef NS_ENUM(NSInteger,Product)
{
Juice = 0,
water,
coffee
};
typedef NS_OPTIONS(NSInteger, Options)
{
Option1 = 1 << 0,
Option2 = 1 << 1,
Option3 = 1 << 2
};
@interface ProductSelectionForm : NSObject < FXForm >
@Property (nonatomic, assign)Product productList;
@Property (nonatomic, assign) Options productOptions;
@EnD
Hello,
First and foremost, sorry for bringing this up as an issue, but I couldn't wrap my head around some way of doing this:
I have a basic signup form and have two issues with it so far:
Thank you!
Hi Nick, how do you format the label used to show the currently selected option in an option field like this? I tried optionLabel but doesn't work.
return @{FXFormFieldKey: @"secretQuestion",
FXFormFieldTitle: @"QUESTION (*)",
FXFormFieldOptions: questions,
@"textLabel.font": kFontNormal(14),
@"optionLabel.font": kFontNormal(14)};
Hi there,
Is there any way can let me add a custom button to the form? I've look through the FXForms.h library but don't see any button related functions there.
Correct me if I am wrong ya ๐ hope you have a nice day ahead.
If I have multiple fields, the user has to manually tap the next field while it's much more user-friendly if instead of 'Done', the keyboard displays 'Next' IF there's still another field below the current field, and it then jumps to the next field when pressing Next! :)
Hi Nick,
I have question regarding updating the placeholder and model view communication. I've set up a form where people can search for their city. Therefor I set up a view controller form field like this:
@{ FXFormFieldKey : @"cityViewController", FXFormFieldTitle : NSLocalizedString(@"CITY", nil), FXFormFieldPlaceholder : self.selectedCity },
The cityViewController is presented with a search interface which works quite well. In there I declared a @property NSDictionary
to hold the users selection from the search results. I want to communicate that selection back to the form model and adjust the placeholder string to the current value of the selected city.
I can see that in cityViewController.selectedEntry the current selection is stored so that's working ok. But how can I adjust the placeholder to display the current city accordingly?
I wonder if there might be a better way to do what I try?
Thanks so much for your work and help!
Hi,
First of all - thanks a lot for sharing this project. It's coming in handy.
I believe the following should be added before pushing to a new VC:
[controller.view endEditing:YES];
Otherwise the various inputs stay visible when you pop back to the form from the options screen.
Is there a way to immediately make the first textfield the firstresponder so the keyboard immediately pops up?
I just started using FXForms - looks really promising for reducing work I have to do. My first attempt to implement a form using an NSManagedObject as my FXForm (assume this is valid). Here's my exception:
2014-04-05 16:16:58.530 Lacrosse-Stats[16049:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<team 0xd0781b0> valueForUndefinedKey:]: the entity (null) is not key value coding-compliant for the key "state".'
Apparently, there is no value for the "state" field (a US State). It is not mandatory in my app. I would assume FXForm can handle null values so I must be doing something wrong. Any suggestions?
i.e. Multivalue text field (A list where people can add/delete/modify entries).
When I try to set the FXFormFieldPlaceholder like this:
- (NSArray *)fields
{
return @[
@{ FXFormFieldKey : @"genderType", FXFormFieldTitle : NSLocalizedString(@"REGISTER_DU_BIST", nil), FXFormFieldPlaceholder : @"test" },
}
I get
Use of undeclared identifier 'FXFormFieldPlaceholder'; did you mean 'FXFormFieldHeader'?
Indeed I can't find the declaration for it in FXForms.h. Documentation says there is such a property?!
Is is currently possible to customize the section headers, e.g. changing the font? Or to provide a custom UIView for the section headers?
Hey,
Need some help! I've setup FXForms, great job! But when I setup FXFormFieldOptions, the row appears, but when I tap on it, the next view with the options doesn't load, nothing happens when I tap the row, apart from the changing background colour of the cell.
Please help! Cheers.
Is it possible to set the auto capitalization to off on the text fields?
I tried
@"textField.autocapitalizationType": @(UITextAutocapitalizationTypeNone)
But that causes a crash.
For filling UIImage
properties, using UIImagePickerController
for selection.
Yay or Nay? If welcome I'll try a PR soon
Changing the gender definition in the basic example to
typedef NS_ENUM(NSInteger, Gender)
{
GenderMale = 10,
GenderFemale,
GenderOther
};
does not change the output after submitting the form. (gender is still 0 if male is selected).
I think theres something wrong with the enum handling.
I want to use decimal keyboard for number inputs but I can not force the keyboard I want.
Thanks!
As you say in your ReadMe, I've used a custom setter to intercept a value change within the form. I then use this value to recalculate another value within the same form. How can I now update this form? I've tried calling the 'Fields' method but this doesn't update the data visibly. I know it has been changed because if I scroll the cell out of view and then back the value is changed correctly. But I somehow need to reload the tableview from within the form, do you have an idea how to do this?
On a very simply form I have 3 fields, the second is for date selection. When I select it, the table content moves upwards when there's no need to. It works fine with the normal keyboard/text fields, just not the date picker.
Are there any plans to include form/field validation as a feature for FXForms?
It appears that the delegates are not being cleared when deallocating the Form Objects so if they attempt to fire a delegate method, it results in a selector fired on a deallocated object.
I've fixed it here: boxer@5a4da60
(Sorry - too deep on the fork for a simple pull request and no time to make it work - there's more code to be written!)
I'm currently using FXForms to edit account details in an app I'm working on.
I would like to be able to programmatically add a button to the bottom of the table (to remove the account).
I don't want to have this field on all the FXForms I create using the same class, since the same form is also used for adding new accounts (and they can not be removed, obviously).
Any suggestions on how this can be done?
For iPad apps, it would be really convenient to be able to specify a popover to display fields options or the editor (date picker, for example) instead of inline or nav to to new screen.
Hi Nick,
with this issue I refer to the part of the documentation that states:
If the field type is numeric, and the options values are not numeric, it will be assumed that the field value should be set to the index of the selected item, instead of the value.
When I understand this correctly declaring a field as numeric like this and passing an array with some country strings would result in the property value being set to the selected index in the option table view (countryIndex is of type NSInteger)(?
@{ FXFormFieldKey : @"countryIndex", FXFormFieldTitle : NSLocalizedString(@"COUNTRY", nil), FXFormFieldOptions : self.countries },
However when I output the property value of countryIndex
after I select an option and reload the table view I always get a value of 0. Also there is no checkmark set to the selected option in the table view listing the countries.
Do I misinterpret the documentation here?
I wanted to be able to access basic cell properties without subclassing and I noticed that basically the field is mapped on the cell, hence this works:
@"backgroundColor": [UIColor yellowColor],
So the dictionary becomes:
return @{FXFormFieldKey: @"email",
FXFormFieldTitle: ICLocalizedString(@"FORM_EMAIL*", @""),
FXFormFieldHeader: ICLocalizedString(@"FORM_ACCESS_DATA", @""),
FXFormFieldPlaceholder: ICLocalizedString(@"FORM_EMAIL_PLACEHOLDER", @""),
FXFormFieldType: FXFormFieldTypeEmail,
@"backgroundColor": [UIColor yellowColor],
@"textLabel.font": kFontNormal(14),
@"textField.font": kFontNormal(14)};
Do you agree with this approach or you see anything wrong with it?
Not sure if this is there already, but can't seem to get it to work.
How to display and set another MO entity from a relationship.
For example on the Client Form which points to SalesAgent Entity. How to pick the Sales Agent (which has name, id, etc) display just name and then assign the selected SalesAgent MO to the Client form?
Hi,
Really like FXForms, the idea and the implementation! thanks for sharing your code with us !
Um, also it would be awesome if you can make an example app using the advanced method !
If I set a property to be MFMailComposeViewControler
and the deploy device doesn't have a mail account configured, the form will show the "No Mail Accounts" alert view when the view appears, and then again before the cell is displayed. I've tried to set a default value for the property, but I can't get around it. Any advice?
Hi, does your framework have any support for localization? I think it would be awesome if for any field it would simply make the title of the field NSLocalizedString(fieldTitle, @"");
Then I wouldn't have to implement the 'Fields' method to get the titles localized.
This is relevant to #52: Is there a way to use a FXFormBaseCell
subclass with a text field to update the model object?
When values are displayed on a new screen (not inline), it would be convenient to have an option to return to main form when a value is selected rather than needing to tap the back nav button.
Hi,
I currently have my own form view controller which conforms to the protocol
<FXFormControllerDelegate>
. I've set it up as in the docs:
self.formController = [[FXFormController alloc] init];
self.formController.form = [[MKSignupFormInput alloc] init];
self.formController.tableView = self.tableView;
I've got a field in the form which allows user's to select their country:
@{
FXFormFieldKey : @"country",
FXFormFieldPlaceholder : @"Select your country...",
FXFormFieldTitle : @"Country",
FXFormFieldType : @"option",
FXFormFieldOptions : [CountryPicker countryNames]
}
This field, when tapped, pushes a view controller to show these countries (non-custom). When I select an option, and then tap to go back to the form, the cell within the form is still set as selected, and the value does not get updated to be my selected option.
The workaround I currently use is to manually reload the tableview from my custom form view controller in viewWillAppear.
ceeK
I've tried to subclass FXFormTextFieldCell
with little to no success. All I'd like to do is add an image view to the left of the cell, with a 58pt
x-value. This is my attempt:
#import "FXForms.h"
@interface POnboardingCell : FXFormTextFieldCell
@property (strong, nonatomic) IBOutlet UIImageView *iconImageView;
@end
#import "POnboardingCell.h"
@interface POnboardingCell ()
@property (strong, nonatomic) IBOutlet UITextField *textField;
@end
@implementation POnboardingCell
@synthesize textField = _textField;
- (void)awakeFromNib {
self.textField.frame = CGRectMake(58, 10, 254, 30);
self.textField.textAlignment = NSTextAlignmentLeft;
if (!self.textField.superview) {
[self.contentView addSubview:self.textField];
}
self.iconImageView.backgroundColor = [UIColor greenColor];
}
@end
There is also a .xib
file to accompany the class.
The view loads up, but I cannot interact with the text field.
I'd like to know whether this is already implemented - I could not figure that out - or it is planned in future releases. Thank you very much.
I want to assign some default value to text field cell and picker. How to do that?
Hello,
How do I remove first section header (set its height to 0)?
Do I need to subclass entire formcontroller?
Thank you.
Xcode and CocoaPods are generating documentation already (see http://cocoadocs.org/docsets/FXForms) but currently all the information is in the README.
I'd be happy to submit a PR with the documentation taken from the current README.
Hi,
first of all, great work! When I use "FXFormFieldType: FXFormFieldTypeLongText" property, placeholder is not shown.
Example:
@{FXFormFieldKey: @"citazione", FXFormFieldType: FXFormFieldTypeLongText,FXFormFieldPlaceholder: profilo.prfCitazionePreferita,
@"textLabel.color": mainColor,
@"textLabel.font": labelFont}
@{FXFormFieldKey: @"citazione",FXFormFieldPlaceholder: profilo.prfCitazionePreferita,
@"textLabel.color": mainColor,
@"textLabel.font": labelFont}
Suggestions?
Best regards
Costantino
Have you had any thoughts about how to structure Conditional and Dependent fields? I'm working through very specific use-case of replicating Apple's event creation form (EKEventEditViewController) for a custom calendar that cannot use EKEventStore. Problem here is the date-related fields:
First problem is the 'All day' UISwitch field. When enabled, it changes the 'Start' and 'End' field from DateTime to just a Date picker. So this would be a 'Dependent' field relationship to change that setting if value changes.
Second problem is the 'Repeat' field. It's currently a picker and if it equals anything other than 'Never' the form adds a 'End Repeat' field, which is also a picker (or poentially date). So this would be a 'Conditional' field that should only appear if another field's has a particular value or values (possibly using KVO?)
Again, this is very specific use-case, but I'm sure similiar concepts would be beneficial to more forms. Any thoughts on how to work these cases into FXForms? Happy to help contribute, just didn't want to do work one way if you have already considered and just haven't implemented yet.
I need to use my FXForm also in ReadOnly mode. In this mode I set all the fields type as FXFormFieldTypeLabel, but I need also to hide all the empty fields (the hidden fields will be displayed in Edit mode).
All the fields are set via Fields method as UndefinedKeys, there aren't class properties.
Can you suggest me the best way to hide or show empty cells?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.