0

This question already has an answer here:

I have added form id in config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <customer>
            <captcha>
                <shown_to_logged_in_user>
                    <video_form>1</video_form>
                </shown_to_logged_in_user>
                <always_for>
                    <video_form>1</video_form>
                </always_for>
            </captcha>
        </customer>
        <captcha translate="label">
            <frontend>
                <areas>
                    <video_form>
                        <label>Video Form</label>
                    </video_form>
                </areas>
            </frontend>
        </captcha>
    </default>
</config>

after that added captcha with FormId

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
            <block class="Magegadgets\Videoform\Block\Index\Index" name="videoform_index_index" template="Magegadgets_Videoform::videoform_index_index.phtml">
             <container name="form.additional.info" label="Form Additional Info"/>
            </block>
        </referenceContainer>
         <!-- Code Start For Display Captcha on Register page -->
         <referenceContainer name="form.additional.info">
        <block class="Magento\Captcha\Block\Captcha" name="captcha" after="-" cacheable="false">
            <action method="setFormId">
                <argument name="formId" xsi:type="string">video_form</argument>
            </action>
            <action method="setImgWidth">
                <argument name="width" xsi:type="string">230</argument>
            </action>
            <action method="setImgHeight">
                <argument name="width" xsi:type="string">50</argument>
            </action>
        </block>
    </referenceContainer>
    <referenceBlock name="head.components">
        <block class="Magento\Framework\View\Element\Js\Components" name="captcha_page_head_components" template="Magento_Captcha::js/components.phtml"/>
    </referenceBlock>
        <!-- Code End For Display Captcha on Register page-->
    </body>
</page>

after that added template for form

<form class="form revo" enctype="multipart/form-data" action="<?php echo $block->getUrl('videoform/index/postnew')?>" id="custom-form" method="POST"
      data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>" data-mage-init='{"validation":{}}'>
      <input name="type" value="1"  type="hidden" />

      <div class="form-3">  
      <div class="tab-content">
        <div id="signup">   
          <h1>Book Your Free Slot</h1>

          </div>

          <div class="top-row">
            <div class="field required">
            <div class="field-wrap em3">
              <label>
                Name
              </label>
              <input name="fullname" type="text" class="input-text required-entry in"  /> 
            </div>
          </div>

            <div class="field-wrap em2">
              <label>
               Phone
              </label>
              <input name="mobile" type="phone" id="mobile" class="input-text required-entry in" minlength="10" maxlength="12"/>
              <span id="errmsg" style="color: red;text-align:center;"></span>
            </div>


          <div class="field-wrap em">
            <label>
              Email
            </label>
            <input name="email" type="email" class="input-text required-entry validate-email in"  />
          </div>

          <div class="field-wrap em3">
              <label>
               Language
              </label>
              <select name="language" style="width: 100px;">
              <option value="telgu">Telugu</option>
              <option value="hindi">Hindi</option>
              <option value="english">English</option>
              <option value="odiya">Odiya</option>
            </select> 
            </div><br>
             <div class="field-wrap em3 required-entry">
              <label>
               Date
              </label>
             <input name="takedate" id="datepicker" title="Terminwunsch" value="" type="text" class="input-text required-entry in"/>
                    <script type="text/javascript">
                    require([
                        "jquery",
                        "mage/calendar"
                        ], function($){
                             var dateToday = new Date();
                             $('#datepicker').datepicker({
                               prevText: '&#x3c;zur체ck', prevStatus: '',
                                prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
                                nextText: 'Vor&#x3e;', nextStatus: '',
                                nextJumpText: '&#x3e;&#x3e;', nextJumpStatus: '',
                                monthNames: ['Januar','Februar','M채rz','April','Mai','Juni',
                                'Juli','August','September','October','November','December'],
                                monthNamesShort: ['Jan','Feb','M채r','Apr','Mai','Jun',
                                'Jul','Aug','Sep','Oct','Nov','Dec'],
                                dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
                                dayNamesShort: ['So','Mo','Tue','Wed','Thu','Fr','Sa'],
                                dayNamesMin: ['So','Mo','Tue','Wed','Thu','Fr','Sa'],
                              showMonthAfterYear: false,
                              dateFormat:'d.m.yy',
                               minDate: dateToday,
                              yearRange: '2018:2019',
                              changeMonth: true,
                              changeYear: true

                            } 
                          );
                        });
                    </script>
                  </div>
 <div class="field-wrap em3">
              <label>
               Time
              </label>     
<select name="hrs" style="width: 58px;">
<?php 

for($hours=1; $hours<=12; $hours++)
{

    echo "<option value=".$hours.">".$hours."</option>";
}
?> 
<option name="hrs"> </option>   
</select>
<!--<span>select hours </span>-->
<select name="min" style="width: 60px;">
<?php 
for($mins=0; $mins<=60; $mins+=5)
{

    echo "<option value=".$mins.">".$mins."</option>";
}                                
?> 
<option name="min"> </option>   
</select>
<!--<span>select minutes </span>-->
<select name="meri" style="width: 60px;">
  <option value="am">am</option>
  <option value="pm">pm</option>
</select>
<!--<span>select am/pm </span>-->
</div>

          </div>
     <div class="chk" style="display:none;">
        <label class="chk_agree">
        <input type="checkbox" value="">
        <span class="checkmark"></span>
        I agree to the <span class="term">Terms of Services</span>

        </div>
    <?php echo $block->getChildHtml('form.additional.info'); ?>
      <div class="sign_btn">
          <button type="submit" id="submit" class="button button-block"/>Submit</button>
      </div>
      <div class="chk">
      <label class="chk_agree">

      </label>
     </div>

      </div>      
 </form>

marked as duplicate by Community Feb 27 at 11:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • it did not work form me. i tried this code – Sarvesh Tiwari Feb 27 at 11:57
  • Add this into your phtml <?php echo $block->getChildHtml('form.additional.info'); ?> – Prathap Gunasekaran Feb 27 at 11:58
  • I have added this code in my phtml file – Sarvesh Tiwari Feb 27 at 11:59
  • Please try that exactly there. It's an working code tested in magento 2.2 – Prathap Gunasekaran Feb 27 at 12:00
  • I don't see this in your phtml above – Prathap Gunasekaran Feb 27 at 12:01

Browse other questions tagged or ask your own question.