// // <%= @class_name %>Form.m // <%= @project_name %> // // Created by <%= @developer.capitalize %> on <%= @created_on %> // Copyright(c) <%= Time.now.year %>, All rights reserved. // #import "<%= @class_name %>Form.h" @implementation <%= @class_name %>Form @synthesize <%= @project_name %>VO, firstNameTextField, lastNameTextField, emailTextField, <%= @project_name %>nameTextField, passwordTextField, confirmPasswordTextField, mode, delegate; -(id)init { return [super initWithStyle:UITableViewStyleGrouped]; } - (void)loadView { [super loadView]; self.navigationItem.title = @"<%= @class_name %> Profile"; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save<%= @class_name %>)]; self.tableView.scrollEnabled = NO; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; switch (indexPath.row) { case 0: { //First and Last Name self.firstNameTextField = [self textFieldWithPlaceHolder:@"First Name" frame:CGRectMake(10,12,135,25)]; firstNameTextField.text = <%= @project_name %>VO.firstName; [cell.contentView addSubview:firstNameTextField]; self.lastNameTextField = [self textFieldWithPlaceHolder:@"Last Name" frame:CGRectMake(150,12,135,25)]; lastNameTextField.text = <%= @project_name %>VO.lastName; [cell.contentView addSubview:lastNameTextField]; break; } case 1: { //<%= @project_name %>name and email self.emailTextField = [self textFieldWithPlaceHolder:@"Email" frame:CGRectMake(10,12,155,25)]; emailTextField.text = <%= @project_name %>VO.email; [cell.contentView addSubview:emailTextField]; self.<%= @project_name %>nameTextField = [self textFieldWithPlaceHolder:@"<%= @class_name %>name*" frame:CGRectMake(170,12,115,25)]; <%= @project_name %>nameTextField.text = <%= @project_name %>VO.<%= @project_name %>name; if (mode == EDIT) { <%= @project_name %>nameTextField.enabled = NO; } [cell.contentView addSubview:<%= @project_name %>nameTextField]; break; } case 2: { //password and confirm self.passwordTextField = [self textFieldWithPlaceHolder:@"Password*" frame:CGRectMake(10,12,135,25)]; passwordTextField.secureTextEntry = YES; passwordTextField.text = <%= @project_name %>VO.password; [cell.contentView addSubview:passwordTextField]; self.confirmPasswordTextField = [self textFieldWithPlaceHolder:@"Confirm*" frame:CGRectMake(150,12,135,25)]; confirmPasswordTextField.secureTextEntry = YES; confirmPasswordTextField.text = <%= @project_name %>VO.password; [cell.contentView addSubview:confirmPasswordTextField]; break; } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(void)save<%= @class_name %> { <%= @project_name %>VO.firstName = firstNameTextField.text; <%= @project_name %>VO.lastName = lastNameTextField.text; <%= @project_name %>VO.email = emailTextField.text; <%= @project_name %>VO.<%= @project_name %>name = <%= @project_name %>nameTextField.text; <%= @project_name %>VO.password = passwordTextField.text; <%= @project_name %>VO.confirmPassword = confirmPasswordTextField.text; if (mode == NEW) { [delegate create<%= @class_name %>Selected:<%= @project_name %>VO]; } else if (mode == EDIT) { [delegate update<%= @class_name %>Selected:<%= @project_name %>VO]; } } -(UITextField *)textFieldWithPlaceHolder:(NSString *)placeHolder frame:(CGRect)frame { UITextField *textField = [[[UITextField alloc] initWithFrame:frame] autorelease]; textField.placeholder = placeHolder; textField.clearButtonMode = UITextFieldViewModeWhileEditing; textField.autocorrectionType = UITextAutocorrectionTypeNo; return textField; } - (void)dealloc { self.<%= @project_name %>VO = nil; self.firstNameTextField = nil; self.lastNameTextField = nil; self.emailTextField = nil; self.<%= @project_name %>nameTextField = nil; self.passwordTextField = nil; self.confirmPasswordTextField = nil; self.delegate = nil; [super dealloc]; } @end