Polymer - Iron Form

The <iron-form> is an HTML <form> element used to validate and submit any custom elements and native elements. Both the get and post methods are supported and ironajax element is used to submit the data to the action URL.

By default, the native button element submits the following form −

<form is = "iron-form" id = "form" method = "post" action = "/form/handler">
   <paper-input name = "password" label = "Password"></paper-input>
   <input name = "address">

Call the form's submit method explicitly, if you want to submit it from the custom element's click handler as shown in the following command.

<paper-button raised onclick = "submitForm()">Submit</paper-button>

function submitForm() {

The following code shows the iron-form-presubmit event to which you can listen, if you want to customize the request sent to the server.

form.addEventListener('iron-form-presubmit', function() {
   this.request.method = 'put';
   this.request.params = someCustomParams;


To implement the iron-form element, install the necessary elements and import them in your index.html file.

The following example demonstrates the use of iron-form element −

<!DOCTYPE html>
      <base href = "https://polygit.org/polymer+1.5.0/components/">
      <script src = "webcomponentsjs/webcomponents-lite.min.js"></script>
      <link rel = "import" href = "polymer/polymer.html">
      <link rel = "import" href = "iron-form/iron-form.html">
      <link rel = "import" href = "paper-input/paper-input.html">
      <link rel = "import" href = "paper-button/paper-button.html">
      <link rel = "import" href = "paper-dropdown-menu/paper-dropdown-menu.html">
      <link rel = "import" href = "paper-menu/paper-menu.html">
      <link rel = "import" href = "paper-item/paper-item.html">
         .paperbtn {
            background: #4682B4;
            color: white;
            width: 25%;
      <form is = "iron-form" method = "get" action = "/" id = "basic">
         <paper-input class = "paperinput" name = "name" label = "Enter your name" required<
         <input type = "checkbox" name = "vehicle" value = "bike"> I have a bike
         <input type = "checkbox" name = "vehicle" value = "car"> I have a car
         <paper-dropdown-menu class = "menu" label = "Icecream Flavours" name = "Flavours">
            <paper-menu class = "dropdown-content">
               <paper-item value = "vanilla">Vanilla</paper-item>
               <paper-item value = "strawberry">Strawberry</paper-item>
               <paper-item value = "caramel">Caramel</paper-item>
         <paper-button class = "paperbtn" raised onclick = "_submit(event)">Submit</paper-button>
         <paper-button class = "paperbtn" raised onclick = "_reset(event)">Reset</paper-button>
         <h4>You entered the details:</h4>
         <div class = "output"></div>
         function _submit(event) {
         function _reset(event) {
            var form  =  Polymer.dom(event).localTarget.parentElement
            form.querySelector('.output').innerHTML  =  '';
         basic.addEventListener('iron-form-submit', function(event) {
            this.querySelector('.output').innerHTML  =  JSON.stringify(event.detail);


To run the application, navigate to your project directory and run the following command.

polymer serve

Now open the browser and navigate to Following will be the output.

Iron Form
Kickstart Your Career

Get certified by completing the course

Get Started