Comments (2)
fyi - I'm building form programatically
self.form = [[EZForm alloc] init];
self.form.inputAccessoryType = EZFormInputAccessoryTypeStandardLeftAligned;
self.form.delegate = self;
int kTextfieldWidth = VCBOUNDSWIDTH - 20;
int kTextfieldHeight = 20;
CGRect tfRect = CGRectMake(160, 10, kTextfieldWidth, kTextfieldHeight);
firstNameTF = [[UITextField alloc] initWithFrame:tfRect];
firstNameTF.delegate = self;
firstNameTF.placeholder = @"First Name";
firstNameTF.borderStyle = UITextBorderStyleNone;
firstNameTF.layer.shadowOpacity = 1.0;
firstNameTF.layer.shadowRadius = 0.0;
firstNameTF.layer.shadowColor = [UIColor whiteColor].CGColor;
firstNameTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
EZFormTextField *firstName = [[EZFormTextField alloc] initWithKey:kSMFirstName];
firstName.validationMinCharacters = 1;
firstName.inputMaxCharacters = 32;
[self.form addFormField:firstName];
[firstName useTextField:firstNameTF]; // glue the model together
firstName.invalidIndicatorPosition = EZFormTextFieldInvalidIndicatorPositionLeft;
lastNameTF = [[UITextField alloc] initWithFrame:tfRect];
lastNameTF.delegate = self;
lastNameTF.placeholder = @"Last Name";
lastNameTF.borderStyle = UITextBorderStyleNone;
lastNameTF.layer.shadowOpacity = 1.0;
lastNameTF.layer.shadowRadius = 0.0;
lastNameTF.layer.shadowColor = [UIColor whiteColor].CGColor;
lastNameTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
EZFormTextField *lastName = [[EZFormTextField alloc] initWithKey:kSMLastName];
lastName.validationMinCharacters = 1;
lastName.inputMaxCharacters = 32;
[self.form addFormField:lastName];
[lastName useTextField:lastNameTF]; // glue the model together
lastName.invalidIndicatorPosition = EZFormTextFieldInvalidIndicatorPositionLeft;
emailTF = [[UITextField alloc] initWithFrame:tfRect];
emailTF.delegate = self;
emailTF.placeholder = @"[email protected]";
emailTF.borderStyle = UITextBorderStyleNone;
emailTF.layer.shadowOpacity = 1.0;
emailTF.layer.shadowRadius = 0.0;
emailTF.layer.shadowColor = [UIColor whiteColor].CGColor;
emailTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
emailTF.autocapitalizationType = UITextAutocapitalizationTypeNone;
emailTF.clearButtonMode = UITextFieldViewModeWhileEditing;
emailTF.keyboardType = UIKeyboardTypeEmailAddress;
emailTF.autocorrectionType = UITextAutocorrectionTypeNo;
/*
* Add an EZFormTextField instance to handle the email address field.
* Enables a validation rule that requires an email address format "[email protected]"
* Limits the input text field to 128 characters maximum (when hooked up to a control).
*/
EZFormTextField *email = [[EZFormTextField alloc] initWithKey:kSMEmail];
email.inputMaxCharacters = 128;
[email addValidator:EZFormEmailAddressValidator];
[email addInputFilter:EZFormEmailAddressInputFilter];
[email addValidator: ^BOOL (id value) {
return value != nil;
}];
[self.form addFormField:email];
[email useTextField:emailTF];
confirmEmailTF = [[UITextField alloc] initWithFrame:tfRect];
confirmEmailTF.delegate = self;
confirmEmailTF.placeholder = @"[email protected]";
confirmEmailTF.borderStyle = UITextBorderStyleNone;
confirmEmailTF.layer.shadowOpacity = 1.0;
confirmEmailTF.layer.shadowRadius = 0.0;
confirmEmailTF.layer.shadowColor = [UIColor whiteColor].CGColor;
confirmEmailTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
confirmEmailTF.autocapitalizationType = UITextAutocapitalizationTypeNone;
confirmEmailTF.autocorrectionType = UITextAutocorrectionTypeNo;
confirmEmailTF.clearButtonMode = UITextFieldViewModeWhileEditing;
confirmEmailTF.keyboardType = UIKeyboardTypeEmailAddress;
confirmEmailTF.autocorrectionType = UITextAutocorrectionTypeNo;
EZFormTextField *confirmEmail = [[EZFormTextField alloc] initWithKey:kSMEmailConfirm];
confirmEmail.inputMaxCharacters = 128;
// [confirmEmail addValidator:EZFormEmailAddressValidator];
// [confirmEmail addInputFilter:EZFormEmailAddressInputFilter];
[self.form addFormField:confirmEmail];
[confirmEmail useTextField:confirmEmailTF];
confirmEmail.invalidIndicatorPosition = EZFormTextFieldInvalidIndicatorPositionLeft;
postcodeTF = [[UITextField alloc] initWithFrame:tfRect];
postcodeTF.delegate = self;
postcodeTF.placeholder = @"";
postcodeTF.borderStyle = UITextBorderStyleNone;
postcodeTF.layer.shadowOpacity = 1.0;
postcodeTF.layer.shadowRadius = 0.0;
postcodeTF.layer.shadowColor = [UIColor whiteColor].CGColor;
postcodeTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
postcodeTF.keyboardType = UIKeyboardTypeNumberPad;
EZFormTextField *postcode = [[EZFormTextField alloc] initWithKey:kSMPostcode];
postcode.inputMaxCharacters = 4;
[self.form addFormField:postcode];
[postcode useTextField:postcodeTF];
postcode.invalidIndicatorPosition = EZFormTextFieldInvalidIndicatorPositionLeft;
dobTF = [[UITextField alloc] initWithFrame:tfRect];
dobTF.delegate = self;
dobTF.placeholder = @"Select";
dobTF.borderStyle = UITextBorderStyleNone;
dobTF.layer.shadowOpacity = 1.0;
dobTF.layer.shadowRadius = 0.0;
dobTF.layer.shadowColor = [UIColor whiteColor].CGColor;
dobTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
EZFormDateField *dob = [[EZFormDateField alloc] initWithKey:kSMDOB];
[dob addValidator: ^BOOL (id value) {
return value != nil;
}];
[dob useTextField:dobTF];
[df setDateFormat:kBupaFormat];
[df setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
dob.outDateFormatter = df;
UIDatePicker *datePicker = [UIDatePicker new];
datePicker.datePickerMode = UIDatePickerModeDate;
dob.inputView = datePicker;
[self.form addFormField:dob];
passwordTF = [[UITextField alloc] initWithFrame:tfRect];
passwordTF.delegate = self;
passwordTF.placeholder = @"Password";
passwordTF.borderStyle = UITextBorderStyleNone;
passwordTF.layer.shadowOpacity = 1.0;
passwordTF.layer.shadowRadius = 0.0;
passwordTF.layer.shadowColor = [UIColor whiteColor].CGColor;
passwordTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
passwordTF.secureTextEntry = YES;
EZFormTextField *password = [[EZFormTextField alloc] initWithKey:kSMPassword];
password.inputMaxCharacters = 10;
[self.form addFormField:password];
[password useTextField:passwordTF];
confirmPasswordTF = [[UITextField alloc] initWithFrame:tfRect];
confirmPasswordTF.delegate = self;
confirmPasswordTF.placeholder = @"Password";
confirmPasswordTF.borderStyle = UITextBorderStyleNone;
confirmPasswordTF.layer.shadowOpacity = 1.0;
confirmPasswordTF.layer.shadowRadius = 0.0;
confirmPasswordTF.layer.shadowColor = [UIColor whiteColor].CGColor;
confirmPasswordTF.layer.shadowOffset = CGSizeMake(0.0, -1.0);
confirmPasswordTF.secureTextEntry = YES;
EZFormTextField *confirmPassword = [[EZFormTextField alloc] initWithKey:kSMPasswordConfirm];
confirmPassword.inputMaxCharacters = 10;
[self.form addFormField:confirmPassword];
[confirmPassword useTextField:confirmPasswordTF];
EZFormBooleanField *subscribeField = [[EZFormBooleanField alloc] initWithKey:kAgree];
[subscribeField setFieldValue:@YES];
[self.form addFormField:subscribeField];
[self.form autoScrollViewForKeyboardInput:myTableView];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.textLabel.font = DEFAULT_FONT(14);
cell.textLabel.textColor = NEVADA;
cell.accessoryType = UITableViewCellAccessoryNone;
if (indexPath.row == 0) {
cell.textLabel.text = @"First Name";
NSString *str = [self.form modelValueForKey:kSMFirstName];
cell.detailTextLabel.text = str;
[cell addSubview:firstNameTF];
}
if (indexPath.row == 1) {
cell.textLabel.text = @"Last Name";
NSString *str = [self.form modelValueForKey:kSMLastName];
cell.detailTextLabel.text = str;
[cell addSubview:lastNameTF];
}
if (indexPath.row == 2) {
cell.textLabel.text = @"Email";
NSString *str = [self.form modelValueForKey:kSMEmail];
cell.detailTextLabel.text = str;
[cell addSubview:emailTF];
}
if (indexPath.row == 3) {
cell.textLabel.text = @"Confirm Email";
NSString *str = [self.form modelValueForKey:kSMEmailConfirm];
cell.detailTextLabel.text = str;
[cell addSubview:confirmEmailTF];
}
if (indexPath.row == 4) {
cell.textLabel.text = @"Postcode";
NSString *str = [self.form modelValueForKey:kSMPostcode];
cell.detailTextLabel.text = str;
[cell addSubview:postcodeTF];
}
if (indexPath.row == 5) {
cell.textLabel.text = @"DOB";
[cell addSubview:dobTF];
}
if (indexPath.row == 6) {
cell.textLabel.text = @"Password";
NSString *str = [self.form modelValueForKey:kSMPassword];
cell.detailTextLabel.text = str;
[cell addSubview:passwordTF];
}
if (indexPath.row == 7) {
cell.textLabel.text = @"Confirm Password";
NSString *str = [self.form modelValueForKey:kSMPasswordConfirm];
cell.detailTextLabel.text = str;
[cell addSubview:confirmPasswordTF];
}
if (indexPath.row == 8) {
cell.textLabel.text = @"I agree to receive e-newsletters from Smiling Minds.";
NSString *response = @"";
BOOL isTicked = [[self.form modelValueForKey:kAgree] boolValue];
if (isTicked) {
response = @"Yes";
}
else {
response = @"No";
}
JSFlatButton *btn0 = [[JSFlatButton alloc]initWithFrame:CGRectMake(160, 5, 80, 80)];
[btn0 setFlatTitle:response];
btn0.buttonForegroundColor = [UIColor whiteColor];
btn0.buttonBackgroundColor = CASABLANCA;
[btn0 bk_addEventHandler: ^(id sender) {
EZFormBooleanField *subscribeField = [self.form formFieldForKey:kAgree];
[subscribeField toggleValue];
[myTableView reloadData];
return;
} forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btn0];
}
if (indexPath.row == 9) {
JSFlatButton *btnUpdate = [[JSFlatButton alloc]initWithFrame:CGRectMake(10, 5, VCBOUNDSWIDTH - 20, 60)];
[btnUpdate setFlatTitle:@"Sign Up"];
btnUpdate.buttonForegroundColor = [UIColor whiteColor];
btnUpdate.buttonBackgroundColor = CASABLANCA;
[btnUpdate bk_addEventHandler: ^(id sender) {
[self submit];
} forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btnUpdate];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone; // don't highlight
return cell;
}
from ezform.
my bad - initWithStyle:UITableViewCellStyleValue1 was the culprit.
switched to use
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
and all good.
from ezform.
Related Issues (20)
- Problems with EZFormRadioField with array updated dinamically based on value in another fiels HOT 4
- Documentation
- EZFormRadioField UIPickerView background HOT 2
- What is the best practice of using EZForm with non-static table view cells? HOT 2
- Can't get the key value when using setChoicesFromKeys HOT 1
- form: fieldDidEndEditing: delegate method doesn't get called on UITextViews HOT 3
- EZFormRadioField.valueOrUnselectedAtIndex throws NSInvalidArgumentException HOT 1
- Unexpected multi radio form field behaviour HOT 1
- Clarification on setting a simple EZFormField HOT 1
- Please update your usage notes :) HOT 2
- Bug when use UITextField with autocorrection
- How to dinamically remove a Validator from a field HOT 1
- Is it possible to show cell separator? HOT 1
- Bump version to 1.1.5? HOT 4
- EZForm delegate not calling HOT 1
- EZFormValueTransformer.m:63:33: Implicit conversion from nullable pointer 'id _Nullable' to non-nullable pointer type 'id _Nonnull' HOT 2
- access the data saved in forms and save them NSUserDefault?
- Xcode 9 installation Error HOT 2
- How use with tableView and fields inside tableViewCells
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ezform.