ortuman / swiftforms Goto Github PK
View Code? Open in Web Editor NEWA small and lightweight library written in Swift that allows you to easily create forms.
License: MIT License
A small and lightweight library written in Swift that allows you to easily create forms.
License: MIT License
So the formValues() returns a field nil if its a .Text and has spaces, plus the spaces aren't applied when you add one, instead they are applied once you start typing characters after
HI, Im using storyboards and my forms works with UITableViewController but I want my form on a ViewController, I can't make it work, always get:
2014-12-26 17:08:54.648 DashPress[56575:5932120] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "uow-b7-lA0-view-7XT-Sf-C3R" nib but didn't get a UITableView.'
I read the Cell appearance
part but cannot catch how to set the custom variables? Where are these custom variable names to set?
Thanks
How to disable rows?
Is there a way to link to another dependent form?
Thanks for such a robust class. I'm using a row's configuration to set style attributes of my form - like so:
row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ...
Is there a way to style the header labels for each FormSectionDescriptor ?
Are there any plans or suggestions for adding selectors like date and time inline (calendar app, etc), rather than sliding up from the bottom? I realize sliding from the bottom is the default functionality in iOS, and sliding down subsequent rows and displaying the selector directly beneath the field is not simple functionality to add. I've gone through the pain of doing this in the past. What are your thoughts on this functionality being part of this library?
Thanks for the great project.
I have a scenario where a user may select auto-fill a form by copying a record. I can successfully retrieve the record, but I'm not sure how to go about setting the form row values and having those values reflected in the UI.
The approach I am using presently is to iterate over the rows in each section and setting row.value to my value.
Any tips would be greatly appreciated.
Sincerely,
@padotj
How can I make the picker disappear when tapping elswhere on the screen? (i.e. outside any other formcells)
usually something like:
`override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
self.view.endEditing(true)
}`
works, but I don't know where to put it to get it work...
Any ideas?
btw: this is a great piece of coding! Thanks for sharing!
THX!
Kinzi
Is it possible to customize the FormSectionDescriptor for example setting the footer text to center and add a UIImageView?
XLForm can open modal UIViewController by clicking on a line in the form which has an arrow to the right.
Is it possible to do something like this with SwiftForms?
I set row.value = 1234
, but there appears no value in the cell.
Thanks
I'm pushing data from one view controller to the FormViewController but the form returns a null when the text is prefilled. Is there a way around this?
var row: FormRowDescriptor! = FormRowDescriptor(tag: Static.emailTag, rowType: .Email, title: "Email")
row.configuration[FormRowDescriptor.Configuration.CellConfiguration] = ["textField.text" : "[email protected]", "textField.textAlignment" : NSTextAlignment.Right.rawValue]
Gender selector does not disapear in the Demo
Rows with .Password as RowType cannot handle more than one character. I have tested this on an iPhone 5, iPad retina and the simulator. I have not found a way to fix/circumvent this bug.
Tested on Xcode 6.1.1 and Yosemite 10.10.1; using SDK 8.1 on iOS 8.1.2
I'm creating a form, and when I don't change the value of the Switch. It doesn't get added into the FormValues dictionary (I'm getting null); it only does when I change the switch to On.
I have a subclass SettingController: FormViewController
. I do not use a Storyboard or interfacebuilder.
How can I init the subclass in code?
I tried
init() {
super.init(style: UITableViewStyle.Grouped)
self.form = getForm()
}
but this raised the error:
fatal error: use of unimplemented initializer 'init(nibName:bundle:)' for class 'Test.SettingController'
It looks that requisite delegates/methods not set in given source. How can I dismiss keypad or picker view in the project?
I add a new swift file like 'FormPickerCell' named 'FormTwoComponentPickerCell'. I want to use picker with two components.
I extend FormRowType also as follows
enum FormRowType {
...
case Picker
case TwoComponentPicker
...
}
When i add this new class to FormViewController in function defaultCellClassForRowType like
Static.defaultCellClasses[FormRowType.TwoComponentPicker] = FormTwoComponentPickerCell.self
Xcode says 'Use of unresolved identifier 'FormTwoComponentPickerCell''.
By the way, the new class added just the same as FormPickerCell except class name.
Could any one give me a hit? thanks.
您好,我使用代码new 继承FormViewController。如何初始化呢?谢谢~~~
Have not been able to use this programmatically. I had to create the view controller in a storyboard to use it which was very frustrating.
From the example in the docs you have to have a predetermined array of choices for the switch statement. Is it possible to have a dynamic array using a for loop or something?
Hi @ortuman,
first of all: Great lib, I wish it would work for me as it is really useful for setting up settings.
As soon as I start using your code (see below example), I can't restart the next debugging session anymore (Cmd + R). I'll get the following popup:
Then I have to restart Simulator and Xcode in order to get it working again. This happens every time.
Also when I stop the session manually it crashes without exception.
I use the table view controller as a modal popup. The navbar buttons are linked with interface builder to the actions. Did you experience this behavior yourself already? Any idea? Thanks in advance.
import Foundation
import UIKit
class FilterViewController: FormViewController {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let form = FormDescriptor()
let section1 = FormSectionDescriptor()
section1.headerTitle = "Test"
var row: FormRowDescriptor! = FormRowDescriptor(tag: "test", rowType: .Email, title: "Email")
row.cellConfiguration = ["textField.placeholder" : "[email protected]", "textField.textAlignment" : NSTextAlignment.Right.rawValue]
section1.addRow(row)
form.sections = [section1]
self.form = form
}
@IBAction func handleCancel() {
println("close")
dismissViewControllerAnimated(true, nil)
}
@IBAction func handleApply() {
println("save")
dismissViewControllerAnimated(true, nil)
}
}
Sorry for being a swift newbie but how do I use this in my project? Can it be included as a framework?
I tried a couple of way but without success so far.
Thanks
Not sure if this is doable. What if I want to add my own cell in the form?
This was causing some issues in my code, I think single values should be saved as that value. To fix just change
formCell.rowDescriptor.value = NSMutableArray(object: optionValue)
to
formCell.rowDescriptor.value = optionValue
in FormOptionsSelectorController.swift
@ortuman CocoaPods 0.36-pre adds support for Swift :)
It'd be great if SwiftForms can be submitted to CocoaPod's master repo, what do you think?
Hey, could you please tell me if there is a way to set a picker value to one of its options? If the picker itself were exposed I could use something like 'picker.selectRow', but I don't see it? Thank you!
Hi, thank you for great library! I'm trying to figure out how to unset already set date picker value. For example birthday in example form application. Thank you.
Hi I have a form with 3 objects, .Email .MultipleSelector .MultilineText and a .Button.
If I only fill the MultiLineText I get Null on it, but If I fill any other I get the value from the MultiLineText
Instead of using the placeholder fields I would like to pre-fill the fields directly from the database. How would I do that? Thanks for the help.
I will appreciate if you can add ImagePicker support from gallery and with camera just like FXForms
How do I use this as a pod? I'm upgrading to Swift 2 and have no idea how to upgrade this also.
FormDescriptor#validateForm
is not public.
There does not seem to be a built-in way to validate fields based on FormRowDescriptor.Configuration.Required
.
Is this intentional?
// SwiftForms/descriptors/FormDescriptor.swift
func validateForm() -> FormRowDescriptor! {
for section in sections {
for row in section.rows {
if let required = row.configuration[FormRowDescriptor.Configuration.Required] as? Bool {
if required && row.value == nil {
return row
}
}
}
}
return nil
}
Hi is there a simple way of adding form rows dynamically based on something picked in previous row?
Hey, I am trying to set a value using a MultipleSelector row, and can't figure out how to select one of the values by doing something such as row.value = "example"
In my code its for the purpose of editing an item after creating it.
In the example:
row = FormRowDescriptor(tag: Static.categories, rowType: .MultipleSelector, title: "Categories")
row.configuration[FormRowDescriptor.Configuration.Options] = [0, 1, 2, 3, 4]
row.configuration[FormRowDescriptor.Configuration.AllowsMultipleSelection] = true
row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in
switch( value ) {
case 0:
return "Restaurant"
case 1:
return "Pub"
case 2:
return "Shop"
case 3:
return "Hotel"
case 4:
return "Camping"
default:
return nil
}
} as TitleFormatterClosure
if I was to do:
row.titleForOptionValue("Restaurant");
or row.titleForOptionValue(0);
or row.value = "Restaurant"
or row.title = "Restaurant"
Then the selected option still shows up as nothing
How can I get it so that it displays one of the options by default when the form loads?
Thanks
OSX: 10.10.1
XCode: 6.1.1
Testing given example displays nothing in Gender picker options when running in simulator. Clicking on blank row though displays data/value changes in Gender cell.
Is there a way to add Country and State picker view
The state list should change based on Country.
Is there any way to do it? Please help
I want to add a row that contains only static text. any plans on making it as an additional feature?
Hi,
I haven't found a way to attach any action to a tap of a FormButtonCell (and the example adds a button but doesn't react to it being tapped).
Shouldn't there be an option to attach a closure or a selector to it somewhere?
Thank you!
A button to make the number negative or positive would be nice.
Hi, great plugin. I am using something similar to the category list to have multiple selections, I would like to have some or all checked since the form will be in edit mode. It works great for setting the selected but I can no longer make any changes to the field. The following is my row for my medical app. I appreciate any help.
I am using swift 1.2 with xcode 6.3.2 and targeted for ios 8 >
row = FormRowDescriptor(tag: Static.incidents, rowType: .MultipleSelector, title: "Incidents")
row.configuration[FormRowDescriptor.Configuration.Options] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
row.configuration[FormRowDescriptor.Configuration.AllowsMultipleSelection] = true
row.value = [4,8]
row.configuration[FormRowDescriptor.Configuration.TitleFormatterClosure] = { value in
switch( value ) {
case 1:
return "Meds - missed or refused to take"
case 2:
return "Missed meal / ate little or nothing"
case 3:
return "Unmanaged urinary incontinence"
case 4:
return "Unmanaged bowel incontinence"
case 5:
return "Stumble/near-fall"
case 6:
return "Fall"
case 7:
return "Alcohol/substance abuse during visit"
case 8:
return "Emergency room visit"
case 9:
return "Violent behavior, struck caregiver, pulled hair"
case 10:
return "Unable to rise (new event)"
case 11:
return "Unable to go up/down stairs (new event)"
case 12:
return "Notable increase in bathroom trips"
case 13:
return "Notable decline in ADL capacity"
case 14:
return "Increased confusion"
case 15:
return "Increased agitation or combativeness"
case 16:
return "Increased listlessness or depression"
default:
return nil
}
} as TitleFormatterClosure
// row.value = [4,8] <-- Tried here too but same result....
section2.addRow(row)
Hello guys, i'm having this issue and i really dont know how to fix it!, any idea?
Check dependencies
Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID “(null)” were found.
CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS 8.4'
Thank you
I need to pass a value on init, and instantiate the FormViewController subclass in code.
I have this in my subclass:
init(UUID: String)
{
super.init(nibName: nil, bundle: nil);
self.UUID = UUID
self.loadForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
It calls the custom init, but I get this error:
assertion failed: self.form property MUST be assigned!: file /Users/ransom/jobs/sendcontact/sendcontact-ios/SwiftForms/SwiftForms/Source/controllers/FormViewController.swift, line 62
Is use of a storyboard required? Is there some other super.init i can call?
If I call super.init(syle: .Grouped) I get this error:
fatal error: use of unimplemented initializer 'init(nibName:bundle:)' for class 'SendContact.CardFormController'
创建自己的cell 报这错误 Use of unresolved identifier 'rowDescriptor'
怎么办?
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.