• Resolved markoarula

    (@markoarula)


    Hi,

    I have couple of forms made with your plugin and I have an issue with updating.
    When I refresh edit form page, “Save form” button is displayed and when I make any changes on form this button will become “Update”. When I click on “Update” button nothing happens and there is no way to update the form.

    There is no errors in console or something suspicious.

    Can you help me with this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    Hi markoarula,
    it works very similarly to WordPress’ default page editor Gutenberg.

    I believe your confusion is coming from the difference between updating a form block/field, and updating the form itself.

    When you select a block/field, you are now editing that block, and the sidebar updates to show all the relevant options with the ability to “update” to save the changes made to that block.

    In order to change and update the settings of the form itself, you can either click any blank space on the form that is not a block, or better yet, select “form” from the sidebar. This will switch the sidebar settings to the form instead of the selected block.

    Thread Starter markoarula

    (@markoarula)

    You are right, I was on the field all the time and when I click on blank space “Save form” button appears again.

    Feel a bit stupid, but then again it is a bit confusing.

    Thanks for the help.

    I have one more question, is there a way to put a word or character limit on textarea field.

    Plugin Author Harmonic Design

    (@harmonic_design)

    No worries, it’s easy to miss if you’ve never used a block based editor like this before, and the fact that I don’t have a tutorial or video doesn’t help either!

    HDForms does not have a native way to set character limits, but it IS absolutely possible, as long as you are willing to add a small code snippet to your theme’s functions.php. If you are unable or unwilling to do this, then that’s OK, you can ignore everything below.

    – – – – – – – – – – – – – – – – – – –

    I built in “actions” to HDForms that allows us to run custom functions at different times in the form process such as on form initialize, before form submits, and after form submits.

    In our case, we can use the on init action to set a maxlength of your textarea field.

    The function you will need to add to your theme’s functions.php file is. The below will look complicated, but that’s really only because I will be going into depth explaining how everything works ??

    function hdf_custom_textarea_limit($formid)
    {
    ?>
    <script>
    function hdf_custom_textarea_limit()
    {
    const maxlength = 10; // set the maximum character limit
    const fieldID = "hdf_textarea_XXXXXX"; // replace with the field ID of the textarea
    const el = document.getElementById(fieldID);
    el.setAttribute("maxlength", maxlength);
    }
    </script>
    <?php
    }
    add_action("hdf_after", "hdf_custom_textarea_limit", 10, 1);

    REMEMBER TO MAKE A BACKUP of the file in case you make a mistake copy/pasting.

    In that function, there are two variables that you will need to edit.

    maxlength is currently set to 10, but you can change it to any number you need.
    fieldID is the ID of your textarea field. This can be found by editing the form and clicking on the textarea field. In the sidebar, you will see something similar to “hdf_textarea_xxxxxx”. This is the ID that you need. We can also apply the change to ALL textareas if that’s what you prefer – just let me know.

    And finally, you need to tell the form to run that custom function when the form has initialized. To do this, edit the form, and under Form Settings, select “extra +” at the bottom of the sidebar. Enter hdf_custom_textarea_limit in the “Form init” field.

    Thread Starter markoarula

    (@markoarula)

    Great, I’ll add that script to the function.php

    I would like to apply this change for all textarea fields.

    Thank you for you help and fast replies ??

    Thread Starter markoarula

    (@markoarula)

    One more thing that I forgot to ask.
    Is there a way to save the entries in wp dashboard?

    Plugin Author Harmonic Design

    (@harmonic_design)

    Not a problem. You can replace the above code with the following to set the character limit for all textareas.

    function hdf_custom_textarea_limit($formid)
    {
    ?>
    <script>
    function hdf_custom_textarea_limit()
    {
    const maxlength = 10; // set the maximum character limit
    const el = document.getElementsByClassName("hdf-textarea");
    for(let i = 0; i < el.length; i++){
    el[i].setAttribute("maxlength", maxlength);
    }
    }
    </script>
    <?php
    }
    add_action("hdf_after", "hdf_custom_textarea_limit", 10, 1);

    As for saving the form submissions to the dashboard – it is possible using the aforementioned after_submit action. Using this, we could create a custom function to save the results to WordPress, but unfortunately, this would require more custom code than writing a simple snippet for you here.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.