
    J.A. TERRY, Brian A. Terry, Keith A. Terry, and Wanda A. Terry d/b/a Terry and Sons, Appellants/Cross-Appellees, v. James Donald JOHNSON, Bobby J. Johnson and Mary Lang Johnson, Appellees/Cross-Appellants.
    No. BO-337.
    District Court of Appeal of Florida, First District.
    Sept. 29, 1987.
    Rehearing Denied Nov. 8, 1987.
    Marlin M. Feagle, Lake City, for appellants/ cross-appellees.
    Edwin B. Browning, Jr. and Frederick T. Reeves of Davis, Browning, Hardee & Schnitker, Madison, for appellees/cross-appellants.
   FRANK, Associate Judge.

This dispute arises out of a contract for the sale of real property. The contract was not fulfilled and the Terrys, the sellers, sued the Johnsons for its breach. The trial court dismissed the complaint with finality correctly determining that the underlying document was in the nature of a mortgage or security instrument within the meaning of section 697.01, Florida Statutes (1985), thus requiring a foreclosure proceeding to accomplish its enforcement. See Adkinson v. Nyberg, 344 So.2d 614, 615 (Fla. 2d DCA 1977) (being in essence a mortgage, the contract is governed by the law applicable to a mortgage foreclosure). It denied, however, the Terrys’ motion for leave merely to amend the complaint to seek the appropriate relief. The Terrys have appealed from the final judgment and the Johnsons have cross-appealed the trial court’s rejection of their contention that res judicata barred a subsequent foreclosure proceeding. We reverse the trial court’s order of dismissal; we find no merit in the cross-appeal in the light of Hardee v. Gordon Thompson Chevrolet, Inc., 154 So.2d 174 (Fla. 1st DCA 1963), in which this court determined that the dismissal of a complaint for failure to state a cause of action on one pleaded theory does not create a bar to the filing of an action on a different theory of recovery.

The Terrys urge the view that section 697.01 armed the Johnsons with an affirmative defense but it was waived by not having been raised by motion or in the responsive pleading. See Rule 1.140(h)(1), Fla.R.Civ.P. The defect we find in the Terrys’ contention derives from rule 1.140(h)(2), Florida Rules of Civil Procedure. That rule contemplates that the defense of failure to state a cause of action or a legal defense may be raised by motion for judgment on the pleadings or at the trial on the merits. See Curdo v. Cessna Finance Corp., 424 So.2d 868, 872 (Fla. 4th DCA 1982) (such motion can be made as late as the trial of an action but not thereafter). The facts alleged in the Terrys’ complaint stated a cause of action remediable through foreclosure, but not upon the claim that the Johnsons breached the contract. Thus, the trial court properly considered the section 697.01 defense raised for the first time by the Johnsons at trial. Curdo.

We do find merit, however, in the Terrys' second contention that the trial court erred in denying their motion for leave to amend the complaint. As a general rule, leave to amend is liberally granted and especially in a case such as this where the amendment is based upon the same conduct, transaction and occurrence giving rise to the action in its original form. See Sarasota Commercial Refrigeration and Air Conditioning, Inc. v. Schooley, 381 So.2d 1141, 1144 (Fla. 2d DCA 1980). Although a plaintiff’s ability to achieve amendment of the complaint diminishes as the litigation progresses, the amendment sought by the Terrys, albeit “late in the game,” was merely a technical change in the form of the action and imposed no detriment or prejudice upon the Johnsons. See Wackenhut Protective Systems, Inc. v. Key Biscayne Commodore Club Condominium, 350 So.2d 1150 (Fla. 3d DCA 1977); Fla.R.Civ.P. 1.190(a).

The trial court’s final judgment is vacated and this matter is remanded for the conduct of further proceedings consistent with this opinion.

ERVIN and WIGGINTON, JJ., concur.  