How to add a new input form to checkout in Magento 2
This topic describes how to add a new input form to the Checkout page.
Magento provides the ability to add a custom form to any of the checkout steps: Shipping Information, Review and Payment Information, or custom.
In this article, we will demonstrate how to add the new form before the Shipping Address form.
Related posts
- Add a custom checkout field in Magento 2
- Magento 2 Optimized Checkout Page
- How to customize a checkout step
- Magento 2 one page checkout
- How to add a new step in checkout page
23 Steps to add a new input form to checkout page
- Step 1: Create the form UI component.
- Step 2: Create template of the form.
- Step 3: Register the form in the checkout page layout.
You should know how to create a basic Magento 2 module. All of customized files will be inside this module.
Step 1: Create the form UI component.
First of all, create custom-checkout-form in Mageplaza/HelloWorld/view/frontend/web/js/view directory.
/*global define*/ define([ 'Magento_Ui/js/form/form' ], function(Component) < 'use strict'; return Component.extend(< initialize: function () < this._super(); // component initialization logic return this; >, /** * Form submit handler * * This method can have any name. */ onSubmit: function() < // trigger form validation this.source.set('params.invalid', false); this.source.trigger('customCheckoutForm.data.validate'); // verify that form data is valid if (!this.source.get('params.invalid')) < // data is retrieved from data provider by value of the customScope property var formData = this.source.get('customCheckoutForm'); // do something with form data console.dir(formData); >> >); >);
Step 2: Create template of the form.
Add the knockout.js HTML template custom-checkout-form.html for the form component under the Mageplaza/HelloWorld/view/frontend/web/template directory.
Step 3: Register the form in the checkout page layout.
We will add the new form before the shipping form.
Comparing to our last “Newsletter” component, this form is quite the similar

Except for the fact that the template and the whole form is in the xml itself (children node).
The reason we don’t write a normal html form is because of the way it (the form) declared. Normal html form cannot know how to communicate with the form component (the js file).
-
-
-
-
-
-
-
-
-
-
-
- Mageplaza_HelloWorld/js/view/newsletter
- true
-
- Mageplaza_HelloWorld/js/view/custom-checkout-form
- checkoutProvider
-
- Mageplaza_HelloWorld/custom-checkout-form
-
-
- uiComponent
- custom-checkout-form-fields
-
- Magento_Ui/js/form/element/abstract
-
- customCheckoutForm
- ui/form/field
- ui/form/element/input
- checkoutProvider
- customCheckoutForm.text_field
- Text Field
- 1
- true
- Magento_Ui/js/form/element/boolean
-
- customCheckoutForm
- ui/form/field
- ui/form/element/checkbox
- checkoutProvider
- customCheckoutForm.checkbox_field
- Checkbox Field
- 3
- Magento_Ui/js/form/element/select
-
- customCheckoutForm
- ui/form/field
- ui/form/element/select
-
- Please select value
- Value 1
- value_1
- Value 2
- value_2
- value_2
- checkoutProvider
- customCheckoutForm.select_field
- Select Field
- 2
- Magento_Ui/js/form/element/date
-
- customCheckoutForm
- ui/form/field
- ui/form/element/date
- checkoutProvider
- customCheckoutForm.date_field
- Date Field
- true
Now time to flush cache and test your result. If you have any issue, feel free to leave a comment below, Mageplaza and Magento community are willing to help.


With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.
- How to create a simple Hello World module for Magento 2
- How to Create Controller in Magento 2
- How to create CRUD Models in Magento 2
- How to Create Magento 2 Block, Layout and Templates
- Admin ACL
- How To Create Admin Menu In Magento 2
- Configuration - System.xml
- Admin Grid
- Install / Upgrade script
- Full list of Magento Events & How to Use Them
- How to Create Magento 2 Routing
- Plugin - Interceptor
- Custom Indexers
- Add command line
- Command Line Interface CLI
- How to Add Customer Attribute Programmatically in Magento 2?
- Add Product Attribute
- How to Create Module in Magento 2
- Magento 2 Module Creator - Ultimate Module Generator
- Magento 2 Cache and Page Cache Overview
- Rewrite Controller
- A Guide on How to Create Magento 2 Events & Observers
- Category Attributes
- How to Create Custom REST API in Magento 2
- Create Cron Job Programmatically
- How to Create Shipping Method in Magento 2
- Effective Method to Create Payment Method in Magento 2
- Magento 2 Create Widget
- How to Create Magento 2 Model (in Easy Steps)
- Resource Model - Model Collection
- Factory Object
- Add a custom Zipcode validator
- Clear Cache Programmatically
- File Structure
- 6 Steps to Install Magento 2 on CentOS
- 4 Steps to Install Magento 2 on Mac OSX
- Latest Guide on How to Install Magento 2 on Ubuntu
- 4 Steps to Install Magento 2 on XAMPP Windows
- How to Connect to Magento 2 using Terminal SSH
- Magento 2 Areas vs Modules | A Complete Guide
- 16 Steps to Speed Up Magento 2 to Optimize Your Store
- Create Helper Class
- Enable Disable Developer Mode
- How To Add Custom Columns To Magento 2
- How to make Sidebar sticky
- Add CMS Block in checkout page
- How to Add Custom Tab in Product Page Magento 2
- Add Quick View feature
- Add a Navigation Link in My Account
- Display error Enable error reporting
- Unlock Reindex Process
- Get all payment methods
- Javascript bundling - Group/Combine JS files
- Add Custom Tab in Customer Account
- Disable a Payment Method Programmatically
- Get Customer Collection
- Get Product Collection by Category ID
- Get All Order Collection with Filters
- Get Product Collection Filter By Visibility
- How to Get Review, Rating Collection in Magento 2
- How to Get Best Sellers Collection in Magento 2 (Updated)
- Get Featured Product Collection
- Get Most Viewed Product Collection
- Get New Products Collection
- Get On Sale Products Collection
- Get Recent Viewed Products Collection
- Magento 2 Argument Types - All you need to know
- Get Wishlist Products Collection
- Custom payment method in checkout steps
- Add new fields in address form
- Magento 2 Proxies Explained | The Comprehensive Guide
- Add Product To Cart With Custom Price
- How to Add Products To Category Programmatically in Magento 2
- How to customize the validation rule in Magento 2
- What is Magento 2 API?
- How To Add Extension Attribute To Entity In Magento 2
- How to Use Block Cache in Magento 2?
- Custom shipping address template
- Magento 2 Creating A UI Form
- Magento 2 REST API - Benefits & Implementation Guidelines
- Magento 2 System Configuration Field Types
- Magento 2 Add, Edit Or Delete Action
- Five Steps To Add Mass Actions In Magento 2
- API Authentication: Token, OAuth, Session Authentication
- Latest Guide on How to Add Images To Product in Magento 2
- 4 Steps to Create a Custom Form in Magento 2 Admin
- How to Create Configurable Product with Magento 2 API
- Create Integration Module
- Magento 2 API Create Simple Products
- Magento 2 API Add Simple Products To Configurable Product
- API Functional Testing
- How to Create a Shipment via REST API
- How to issue a refund using API in Magento 2
- Create an Invoice
- Magento 2 API Get Admin Token
- Get All Products, Orders, Categories Details in Magento 2
- Create an Order
- How to Add Products to Cart & Quote in Magento 2
- How to Create a Quote by Calling API in Magento 2
- Shipping and Billing Information
- Create a Customer
- Useful Information of Magento 2 Theme Structure
- Overriding Native Template File
- Magento 2 Overriding Native Layout File
- Add Meta Tags to Header
- Add/Remove Static Files JS, CSS, Fonts
- How to Extend Layout
- How to Create/Reference a Container in Magento 2
- How to Change Block Arguments in Magento 2
- Common Error HTTP Codes in Magento Rest API
- An error has happened during application run. See exception log for details
- How to Get Parent Products for Bundle & Grouped Products in Magento 2
- Resize Product Image
- Check if current url is homepage
- File Upload in System Configuration
- How to get Magento 2 base URL, Current URL in phtml
- Get a block from template file `.phtml`
- How to Get Categories from Specific Product in Magento 2?
- Get currency data: code, rate, symbol
- Get current product, category
- Get Customer Groups
- Get the data of shopping cart items, subtotal, grand total, billing & shipping address
- Get logo url, alt text, logo size
- Get product collection
- How to Get Product by ID, SKU in Magento 2
- Get Product Stock Information
- Get related, upsell & crosssell products
- Get size of product image
- Get store information
- How to Get Value of Product Custom Option from Cart & Order in Magento 2
- Set & Unset session
- Show cms static block from template phtml file
- How to Add Custom Discount in Magento 2
- Add custom fields in Product Edit pages
- Add EAV Attribute
- Add Top Link
- Call children in Template knockout
- Change product price with Plugin
- Convert Custom Field From Quote Item to Order Item
- Create Auto Update Time Attributes in InstallSchema
- Create a New Product Type
- Enable Persistent Shopping Cart
- Get List Products from Catalog Rule Condition
- 6 Steps to Configure Magento 2 Product Custom Options
- Get Stock Items
- Get Value of Custom Attribute via Rest API
- How to Join 2 Tables
- Send Order Email to A Custom Email Address
- Create/Update/Delete Cookie
- Validate Form
- Write to log file
- Upload product image
- Use code in external file/script
- Use Plugin, Preference to rewrite Block, Model, Controller, Helper
- Create CMS pages programmatically
- Create composer.json
- Create customer programmatically
- How to Create Invoice Programmatically in Magento 2 [2024]
- Create order programmatically
- Create product programmatically
- How To Create Shipments Programmatically in Magento 2
- Magento 2 Dependency Injection and Relevant Information
- How to Enable or Disable Modules in Magento 2
- Magento 2 Module load order position
- Magento 2 Registry & Register
- How to Programmatically Add URL Rewrite in Magento 2
- Prompt Widget in Magento 2: What Is It & How to Initialize?
- Sticky Header Component
- What is UI Bookmark Component in Magento 2? | Mageplaza
- How to Upgrade Magento 2 to the Latest Version [3 Methods]
- Using VirtualType
- Add New Total to Email
- How to Create a Custom Theme in Magento 2?
- Enable Guest Checkout in Magento 2: A Step-by-Step Guide
- Custom Shipping Carrier validator
- Add a new input form checkout page
- How to add custom validations before order placement Magento 2
- Magento 2 Unit Test
- Magento 2 Block Template Ultimate Guides
- Create Admin User
- Backup Db, Media, Code
- Magento 2 Deploy Command
- Enable or Disable maintenance mode
- How to Get admin path Command Line in Magneto 2 through Code
- Install / Uninstall Sample Data
- Reindex / Indexer
- Rollback Database, Media, Code
- Run Compile Command Line
- Run cron job manually
- Run Unit Tests
- Enable / Disable Production Mode
- How to Upgrade Magento 2 via Command Line
- Deploy Static Content
- Unlock Admin User
- Add Rel Prev, Next tag
- How to Add, Delete, Re-order Custom Links for My Account Menu / Navigation in Magento 2
- How to Optimize Default Checkout Page in Magento 2
- Use Redis cache for Default Cache and Full page cache
- How to Override Classes in Magento 2 Using Plugin | Unlocked
- How to Enable/Disable Cache in Magento 2
- Create a Unit Test file
- Run Unit Testing
- Package Module
- Add a custom checkout step
- 10 Basic Tutorials
- How to create a simple Hello World module for Magento 2
- Magento 2 Block Template Ultimate Guides
- How to Create Module in Magento 2
- How to Create Controller in Magento 2
- How to create CRUD Models in Magento 2
- How to Create Magento 2 Block, Layout and Templates
- Configuration - System.xml
- How To Create Admin Menu In Magento 2
- Admin ACL
- Admin Grid