AnsPress_Ajax::get_repeatable_field()
Description #
Ajax callback for returning repeatable field group.
Source #
File: includes/ajax-hooks.php
public static function get_repeatable_field() {
if ( ! ap_verify_nonce( 'get_repeatable_field' ) ) {
ap_ajax_json( [ 'success' => false ] );
}
$form_name = ap_sanitize_unslash( 'form_name', 'r' );
$field_name = ap_sanitize_unslash( 'field_name', 'r' );
$count_groups = ap_sanitize_unslash( 'current_groups', 'r' );
$_REQUEST[ sanitize_title( $field_name ) . '-g' ] = $count_groups;
$_REQUEST[ sanitize_title( $field_name ) . '-n' ] = ap_sanitize_unslash( 'current_nonce', 'r' );
$form = anspress()->get_form( 'question' );
$form->prepare();
$field = $form->find( $field_name );
if ( ! empty( $field ) && is_object( $field ) ) {
if ( $field->get_last_field() ) {
ap_ajax_json( array(
'success' => true,
'html' => $field->get_last_field()->output(),
'nonce' => wp_create_nonce( $field_name . ( $count_groups + 1 ) ),
) );
}
}
}
Expand full source code Collapse full source code View on GitHub: includes/ajax-hooks.php:494
Add your comment