     }
 
     public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
-        let idx = responders.index(of: textField)!
-        if idx == responders.count - 1 {
+        let idx = inputViews.index(of: textField)!
+        if idx == inputViews.count - 1 {
             resignResponders()
         } else {
-            nextTextField()
+            nextInputView()
         }
 
         if let delegate = oldTextFieldDelegates[textField], let unwrappedDelegate = delegate, let delegateResponse = unwrappedDelegate.textFieldShouldReturn?(textField) {

        return view
    }

}

extension FormController: UITextViewDelegate {

    public func textViewDidBeginEditing(_ textView: UITextView) {
        currentResponder = textView
        if let delegate = oldTextViewDelegates[textView], let unwrappedDelegate = delegate {
            unwrappedDelegate.textViewDidBeginEditing?(textView)
        }
    }

}

extension FormController: UITextFieldDelegate {

    // MARK: UITextField traversal

    public func textFieldDidBeginEditing(_ textField: UITextField) {
        currentResponder = textField
        if let delegate = oldTextFieldDelegates[textField], let unwrappedDelegate = delegate {
            unwrappedDelegate.textFieldDidBeginEditing?(textField)
        }

public extension FormController {

    func resignResponders() {
        for inputView in inputViews {
            inputView.resignFirstResponder()
        }
    }

}

// MARK: Actions
@objc private extension FormController {

    func donePressed() {
        resignResponders()
    }

    func nextInputView() {
        logger?.logDebug(message: String(format: "[%@] nextInputView", instanceType(self)))
        let nextIdx = inputViews.index(of: currentInputView!)! + 1
        let nextField = inputViews[nextIdx]
        if !nextField.becomeFirstResponder() {
            guard let currentInputView = currentInputView else {
                fatalError("no current input view")
            }
            if !currentInputView.resignFirstResponder() && !currentInputView.endEditing(true) {
                fatalError("could not end editing in input field")
            } else {
                nextField.becomeFirstResponder()
            }
        }
    }

    func previousTextField() {
        logger?.logDebug(message: String(format: "[%@] previousTextField", instanceType(self)))
        let previousIdx = inputViews.index(of: currentInputView!)! - 1
        let previousField = inputViews[previousIdx]
        if !previousField.becomeFirstResponder() {
            guard let currentInputView = currentInputView else {
                fatalError("no current input view")
            }
            if !currentInputView.resignFirstResponder() && !currentInputView.endEditing(true) {
                fatalError("could not end editing in input field")
            } else {
                previousField.becomeFirstResponder()
            }
        }
    }
}

// MARK: Private
private extension FormController {

    func accessoryViewForInputView(view: UIView) -> UIView {
        let previousButton = UIBarButtonItem(title: "Prev", style: .plain, target: self, action: #selector(previousTextField))
        if let idx = inputViews.index(of: view) {
            previousButton.isEnabled = idx > 0
        } else {
            previousButton.isEnabled = false
        }
        let nextButton = UIBarButtonItem(title: "Next", style: .plain, target: self, action: #selector(nextInputView))
        if let idx = inputViews.index(of: view) {
            nextButton.isEnabled = idx < inputViews.count - 1
        } else {
            nextButton.isEnabled = false
        }
