Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Formality hooks reference
<?php
/**
* Formality hooks reference
*
* @link https://formality.dev
* @since 1.1
* @package Formality
* @author Michele Giorgi <hi@giorgi.io>
*/
/**
* Filters reference
*/
add_filter('formality_form_body_classes', function($classes) {
//add or remove body classes from $classes array here
return $classes;
});
add_filter('formality_form_template', function($template) {
//change form template path here
return $template;
});
add_filter('formality_form_header', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_body', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_sidebar', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_nav', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_footer', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_style', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_field', function($html, $field) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_result', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_credits', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_sanitized_data', function($data) {
//edit sanitezed data here
return $data;
}, 10, 2);
/**
* Actions reference
*/
add_action('formality_after_validation', function($data){
//do something here
});
add_action('formality_before_save_data', function($data){
//do something here
});
add_action('formality_before_notification', function($data){
//do something here
});
add_action('formality_after_notification', function($data){
//do something here
});
add_action('formality_after_save_data', function($data, $errors){
//do something here
}, 10, 2);
/**
* JS dom events reference
*/
add_action('wp_print_scripts', function() { ?>
<script>
window.addEventListener("foFieldFocus", function(e) { console.log(e.detail); })
window.addEventListener("foFieldFill", function(e) { console.log(e.detail); })
window.addEventListener("foFormSubmit", function(e) { console.log(e.detail); })
window.addEventListener("foFormSuccess", function(e) { console.log(e.detail); })
window.addEventListener("foFormError", function(e) { console.log(e.detail); })
window.addEventListener("foSidebarOpen", function(e) { console.log(e.detail); })
window.addEventListener("foSidebarClose", function(e) { console.log(e.detail); })
</script>
<?php });
@cattaneoriccardo

This comment has been minimized.

Copy link

@cattaneoriccardo cattaneoriccardo commented Apr 23, 2021

hi michelegiorgi, I believe that row 109
window.addEventListener("foFieldFilled", function(e) { console.log(e.detail); })
should probably change to
window.addEventListener("foFieldFill", function(e) { console.log(e.detail); })

thanks for the great work!

@michelegiorgi

This comment has been minimized.

Copy link
Owner Author

@michelegiorgi michelegiorgi commented Apr 26, 2021

@cattaneoriccardo Thank you for reporting this issue. Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment