Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor ampforwp

    (@ampforwp)

    Hey @alanp57

    Thank you so much for using our plugin.

    Did you add the script?

    To display AMP-form, you have to put a script in the header of AMP version of your website.

    `<script async custom-element=”amp-form” src=”https://cdn.ampproject.org/v0/amp-form-0.1.js”></script&gt;

    Add this script in AMP Settings > Advanced Settings > Paste the script in Enter HTML in Header

    Hope it helps.

    Thread Starter AlanP57

    (@alanp57)

    Thanks for replying.
    I did says, “I have amp-forms loaded.” That means that

    <script async custom-element=”amp-form” src=”https://cdn.ampproject.org/v0/amp-form-0.1.js”></script>

    is on the page. Yet the form HTML is not displayed.

    • This reply was modified 7 years, 8 months ago by AlanP57.
    Plugin Contributor ampforwp

    (@ampforwp)

    Hey @alanp57

    That’s really strange. It must work. Implementing Forms in AMP are quite complex.

    I recommend you to refer AMP documentation thoroughly > https://ampbyexample.com/components/amp-form/ it works out of the box. However, it’s bit complex.

    I have this same problem.
    I have the code for amp-forms and amp-iframe in head.
    I can see the includes in page source.

    Loading iframes works.
    The form, however, is stripped entirely.

    I added the script to the head as well but it seems that AMP strips out the form tags before that script even has a chance to validate them.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @tharkon,

    What issue are you getting?

    Can you share the URL?

    Regards
    Marqas

    As you might be able to tell, the form that appears on the regular page is missing on the AMP. And the AMP also has links to related pages that the regular page does not have.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @tharkon,

    Can you tell me how are you creating that form?

    Regards
    Marqas

    The first form is generated by a custom built plug-in. When that is filled out, a second form built with Gravity forms is displayed.

    I also created a test page here:
    https://www.verbouwkosten.com/test20170718/amp/

    This includes the form code copied directly from ampbyexample.com.

    Plugin Contributor ampforwp

    (@ampforwp)

    Hi @tharkon,

    All form elements are getting stripped by default to validate the page. so if we need any forms to work with in the content then we must need to make sure amp-blacklist sanitizer must be stopped on that page, you need to modify the blacklist sanitizer and unset it from the content sanitizer, so it will not strip the form content and then add the validated form elements and it should work.

    Hope it helps

    Marqas

    Hi @ampforwp,

    We are having the same issue that Tharkon reported. I removed ‘input’, ‘select’ ,
    ‘option’, ‘form’ from the amp-blacklist sanitizer and now our form-element (=calculator) is working properly and the page is still AMP valid.
    We are a bit concerned though what happens if the plugin is updated. I guess the removed elements will be added again to the sanitizer file. Correct?
    As <form> has been supported by AMP for a while by now I would like to know why you don’t remove it from your plugin’s blacklist.

    Thanks a lot for your support.

    What I did, which remains after an update, was add the following to functions.php.

    add_filter( 'amp_content_sanitizers', 'remove_AMP_Blacklist_Sanitizer', 10, 2 );
    
    function remove_AMP_Blacklist_Sanitizer( $sanitizer_classes, $post ) {
    	  unset($sanitizer_classes[ 'AMP_Blacklist_Sanitizer' ]);
    	return $sanitizer_classes;
    }

    But that might be a bit overkill, since it doesn’t just allow forms, it allows everything. I hadn’t noticed the list you mentioned, I might have to play around with that, but there might not be a hook that deep into the class.

    • This reply was modified 7 years, 3 months ago by Tharkon.

    Thank, @tharkon. Nice idea but I also think it is a bit overkill.
    The @ampforwp support could not find any solution. Hopefully they figure smth out soon.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘amp-form?’ is closed to new replies.