feat(contact-form): implement modal contact form with AJAX submission
Replace mailto link with modal popup containing Formidable job application form. Modal stays open after submission to show success message. Changes: - Add modal popup with contact form on job detail pages - Implement AJAX form submission to prevent page reload - Auto-populate job_id field when modal opens - Add field key compatibility for both job_id and job_id2 - Fix form ID comparison to use loose equality - Keep modal open after submission to display success message - Add modal styling and close functionality Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,6 +174,9 @@ class DDHH_JM_Formidable {
|
||||
|
||||
// Hook to pre-populate edit form fields
|
||||
add_filter( 'frm_get_default_value', array( __CLASS__, 'prepopulate_edit_form_fields' ), 10, 3 );
|
||||
|
||||
// Hook to pre-populate job_id in application form
|
||||
add_filter( 'frm_get_default_value', array( __CLASS__, 'prepopulate_application_job_id' ), 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1425,4 +1428,46 @@ class DDHH_JM_Formidable {
|
||||
FrmField::create( $field );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-populate job_id field in application form
|
||||
*
|
||||
* @param mixed $default_value The default value.
|
||||
* @param object $field The field object.
|
||||
* @param bool $dynamic_default Whether to use dynamic default.
|
||||
* @return mixed The modified default value.
|
||||
*/
|
||||
public static function prepopulate_application_job_id( $default_value, $field, $dynamic_default ) {
|
||||
// Only process for the job application form
|
||||
if ( absint( $field->form_id ) !== self::get_job_application_form_id() ) {
|
||||
return $default_value;
|
||||
}
|
||||
|
||||
// Only process the job_id field
|
||||
if ( 'job_id' !== $field->field_key ) {
|
||||
return $default_value;
|
||||
}
|
||||
|
||||
// Check for job_id in shortcode attributes (passed from template)
|
||||
// Formidable stores shortcode attributes in a global variable
|
||||
global $frm_vars;
|
||||
if ( isset( $frm_vars['job_id'] ) ) {
|
||||
return absint( $frm_vars['job_id'] );
|
||||
}
|
||||
|
||||
// Fallback: Check URL parameter
|
||||
if ( isset( $_GET['job_id'] ) ) {
|
||||
return absint( $_GET['job_id'] );
|
||||
}
|
||||
|
||||
// Fallback: Try to get from current post if we're on a single job page
|
||||
if ( is_singular( 'job_offer' ) ) {
|
||||
global $post;
|
||||
if ( $post && 'job_offer' === $post->post_type ) {
|
||||
return absint( $post->ID );
|
||||
}
|
||||
}
|
||||
|
||||
return $default_value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user