• Resolved mitys

    (@mitys)


    Hello, I want to update the default value for the input : postdata-title. I tried all this code but it didn’t work. The only thing that worked is the placeholder.

    $data1 = array(

    ‘post_title_placeholder’ => ‘num client’,
    ‘post_name’ => ‘num client’,
    ‘post_title_name’ => ‘num client’,
    ‘post_title’ => ‘titre du post’,
    ‘value’=> ‘titre du post’,
    /*
    ‘default’ => ‘titre1’,
    ‘value’ => ‘titre2’,
    ‘postdata_title_default’ => ‘titre4’,
    ‘postdata_title_value’ => ‘titre5’,
    ‘placeholder’ => ‘titre6’,
    ‘post_title’ => ‘titre7’,
    ‘post_content’ => ‘titre 8’,
    ‘post_content_label’ => ‘titre 9’,
    ‘post_title_label’ => ‘titre 10’*/
    );

    $fields = Forminator_API::update_form_field( 16048, ‘postdata-1’, $data1 );

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @mitys,

    I hope you are doing well today!

    We are checking your request with our SLS (Second Line Support) team if it is possible to provide a workaround or custom code to achieve this and will inform you accordingly.

    Thanks for the patience while we are looking into the issue.

    Kind regards,
    Zafer

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @mitys,

    Our SLS team provided the following code snippet alternative using jQuery that you can apply to your site as mu-plugin.

    You can find more information below on how to use mu-plugins.
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    
    <?php
    add_action('wp_footer', 'wpmudev_add_default_post_title', 9999 );
    function wpmudev_add_default_post_title() {
        global $post;
        if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
            return;
        }
        ?>
    	<script type="text/javascript">
    	jQuery(document).ready(function($) {
            setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
            }, 100);
    
            $(document).on('after.load.forminator', function(e, form_id) {
                if ( e.target.id == 'forminator-module-1844' ) { // Please change the form ID.
                    $('input[id^="forminator-field-post-title-"]').val('titre du post');
                    $('input[id^="forminator-field-post-title-"]').attr('placeholder', 'num client');
                }
            });
        });
        </script>
        <?php
    }

    Please make sure to change Form ID to yours and test this code on your dev/staging site first.

    Kind regards,
    Zafer

    Thread Starter mitys

    (@mitys)

    Hi, thank you for the workaround, that worked !

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @mitys,

    We are glad to hear that the provided code snippet has been helpful for you and we are marking this thread as resolved accordingly. Please let us know in case you need further help.

    Kind regards,
    Zafer

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Update the form field postdata title in a form’ is closed to new replies.