Custom Field value storage?
danr777 opened this issue · comments
As an example in the "image" custom field, how would one set a value back to the datasource of the form itself?
@danr777 Make it a subclass of FORMBaseFieldCell
and when the value changes you can call the delegate:
if ([self.delegate respondsToSelector:@selector(fieldCell:updatedWithField:)]) {
[self.delegate fieldCell:self
updatedWithField:modifiedField];
}
This will inform FORMDataSource
of the change.
@danr777 are you working on the multi-line field? I might be able to help :)
Hi, Yeah, I give up lol... I tried as an experiment, just changing UITextField to UITextField on the TextField.m's and TextFieldCells.m, but could not figure out one error.. but now i think i'll just make a custom one, now with this It will help ..
I have a whole bunch of custom fields i'd like to make now with this information
Map location selector, Signature collection, Multiselect, multi photo browser w/ in cell preview of all attached thumbnails (in a scrollview)
@danr777 hahaha, wow, all of that sounds nice. How would the map location selector work?
Show a mkmapview which would a default location with one pin in center.
That mkannotation would be draggable
On Fri, Jun 19, 2015 at 2:10 PM Elvis Nuñez notifications@github.com
wrote:
@danr777 https://github.com/danr777 hahaha, wow, all of that sounds
nice. How would the map location selector work?—
Reply to this email directly or view it on GitHub
https://github.com/hyperoslo/Form/issues/428#issuecomment-113594134.
Or even nicer there would a stationary crosshair overlay on map and as you
drag/zoom the map around the crosshair would always stay dead center
On Fri, Jun 19, 2015 at 2:14 PM Dan Russo danrrusso@gmail.com wrote:
Show a mkmapview which would a default location with one pin in center.
That mkannotation would be draggableOn Fri, Jun 19, 2015 at 2:10 PM Elvis Nuñez notifications@github.com
wrote:@danr777 https://github.com/danr777 hahaha, wow, all of that sounds
nice. How would the map location selector work?—
Reply to this email directly or view it on GitHub
https://github.com/hyperoslo/Form/issues/428#issuecomment-113594134.
@danr777 Interesting!
Just not getting it, that line never gets past the first condition: (sorry! thank you for help!!! :) ), i'm sure once I see a working example i'll figure it out:, basically want my textview.text to be my value stored
#import "FORMBaseFieldCell.h"
static NSString *const FORMCustomMultilineCellIdentifier = @"FORMCustomMultilineCellIdentifier";
interface FORMCustomMultilineCell : FORMBaseFieldCell <UITextViewDelegate>
@end
#import "FORMCustomMultilineCell.h"
#import "UIColor+Hex.h"
@implementation FORMCustomMultilineCell
#pragma mark - Initializers
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) return nil;
self.contentView.backgroundColor = [UIColor whiteColor];
self.contentView.layer.cornerRadius = 5.0f;
self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.contentView addSubview:[self container]];
return self;
}
- (void)textViewDidChange:(UITextView *)textView {
if ([self.delegate respondsToSelector:@selector(fieldCell:updatedWithField:)]) {
//NEVER GETS HERE :(
[self.delegate fieldCell:self updatedWithField:self.field];
}
}
- (void)updateWithField:(FORMField *)field {
[super updateWithField:field];
}
- (UILabel *)myLabel {
CGRect labelFrame = CGRectMake(10, 0, CGRectGetWidth(self.frame) - 60, 44);
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
label.font = [UIFont fontWithName:@"AvenirNext-DemiBold" size:14.0];
label.textColor = [UIColor colorFromHex:@"28649C"];
label.text = @"Main title";
return label;
}
- (UITextView *)myTextView {
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 48, CGRectGetWidth(self.frame) - 39, CGRectGetHeight(self.frame) - 100)];
textView.delegate = self;
textView.contentInset = UIEdgeInsetsMake(2, 2, 2, 2);
textView.layer.borderWidth = 1.0f;
textView.layer.borderColor = [[UIColor colorFromHex:@"3DAFEB"] CGColor];
textView.layer.cornerRadius = 5.0f;
textView.backgroundColor = [UIColor colorFromHex:@"C0EAFF"];
return textView;
}
- (UIView *)container {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
[view addSubview:[self myLabel]];
[view addSubview:[self myTextView]];
return view;
}
#pragma mark - Layout
- (void)layoutSubviews {
[super layoutSubviews];
self.contentView.frame = [self contentViewFrame];
}
- (CGRect)contentViewFrame {
CGRect frame = self.frame;
frame.origin.x = 0;
frame.origin.y = 0;
frame.size.width = CGRectGetWidth(self.frame);
frame.size.height = CGRectGetHeight(self.frame);
return frame;
}
@end
@danr777 Sorry, I was wrong, you'll have to use a different method to notify FORMDataSource of your changes. I'm working on improving support for custom fields using the multiline as an example.
Wow that’s great! Thank you
On Mon, Jun 22, 2015 at 5:34 AM Elvis Nuñez notifications@github.com
wrote:
@danr777 https://github.com/danr777 Sorry, I was wrong, you'll have to
use a different method to notify FORMDataSource of your changes. I'm
working on improving support for custom fields using the multiline as an
example.—
Reply to this email directly or view it on GitHub
https://github.com/hyperoslo/Form/issues/428#issuecomment-114050710.
Hi Elvis Nuñez,
I tried to integrate UITextview in this script, but i couldn't get the result. can you post the sample code for UITextView using custom fields.
@rengarajuram I'll take a look
@rengarajuram @danr777 sorry that this took too long, here you go.
Thank you Elvis Nuñez.