Add a new field to form by typing the date


Home Forums Front End PM PRO Add a new field to form by typing the date

This topic is: Resolved
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #44670
    hamed
    Participant

    When I try to add a new field to the form by typing the date, this field is not displayed.
    Can you guide me how to do this?

    Attachments:
    You must be logged in to view attached files.
    #44684
    Shamim Hasan
    Keymaster

    type date is not defined in this plugin by default. You can use fep_form_field_output_date action hook to output date field.

    #44699
    hamed
    Participant

    Dear Shamim,
    Thank you very much for the help you give me.
    To add the date selection field, I added the following code, but nothing is displayed.

    Can you tell me what I should change?

    add_filter( ‘fep_form_field_output_date’, function( $fields ){
    $fields[‘cus_fep_test’] = [
    ‘type’ => ‘date’,
    ‘where’ => ‘newmessage’,
    ‘priority’ => 12,
    ‘label’ => ‘Test’,
    ];
    return $fields;
    });

    add_action( ‘fep_action_message_after_send’, function( $message_id, $message, $new_message ){
    if ( ! empty( $message[‘cus_fep_test’] ) ) {
    fep_add_meta( $message_id, ‘cus_fep_test’, $message[‘cus_fep_test’], true );
    }
    }, 10, 3);

    add_action( ‘fep_display_after_message’, function(){
    if ( $cus_fep_test = fep_get_meta( fep_get_the_id(), ‘cus_fep_test’, true ) ) {
    echo ‘<div>Test : ‘; echo esc_html( $cus_fep_test ) . ‘</div>’;
    }
    });

    #44723
    Shamim Hasan
    Keymaster

    You need to echo from there. Like following (change as you require)

    add_action( 'fep_form_field_output_date', function( $field, $errors ){
        echo 'This is date field';
    }, 10, 2);
    
    #44752
    hamed
    Participant

    This code only changes the text of the error message.
    I want to create a new date type field where the user can specify a date.

    #44755
    hamed
    Participant

    I want to create a field like the attached image.

    Attachments:
    You must be logged in to view attached files.
    #44765
    Shamim Hasan
    Keymaster

    It needs custom code. You can contact me using https://www.shamimsplugins.com/hire/ if you need code help.

    #44771
    hamed
    Participant

    I sent the message.

    #44784
    Shamim Hasan
    Keymaster

    Please add following code in your theme’s (child theme’s if you are using) functions.php

    add_action( 'fep_form_field_output_date', function( $field, $errors ){
        printf( '<input type="%1$s" id="%2$s" class="%3$s" name="%4$s" placeholder="%5$s" value="%6$s" />',
    	esc_attr( $field['type'] ),
    	esc_attr( $field['id'] ),
    	$field['class'],
    	esc_attr( $field['name'] ),
    	esc_attr( $field['placeholder'] ),
    	esc_attr( $field['posted-value' ] )
        );
    }, 10, 2);
    
    #44785
    hamed
    Participant

    thanks a lot.
    you are amazing.

Viewing 10 posts - 1 through 10 (of 10 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.