Support » Plugin: CKEditor WYSIWYG for Gravity Forms » Character Count issue with latest version of Gravity Forms

  • Resolved int3rc3ptor

    (@int3rc3ptor)


    We’re running

    CKEditor WYSIWYG for Gravity Forms version 1.9.3
    Gravity Forms 2.1.1

    on our live environment.

    We have a form that enables users to submit news articles. One of the fields is set as multiline with a 2000 character limit. Since upgrading to GF 2.1.1 no-one is able to submit an article with 2000 characters, it had to be much less around 11-1200 characters before the form would submit correctly.

    On another environment yet to be upgraded to the latest GF we are still running GF 2.0.7 and the form submits fine with a 2000 filled field.

    No messages appear when you inspect and view console upon form submission so on the face of it, there’s no error. Nothing in the GF logs either.

    Looking at the changelog for 2.1.1 looks like these two declarations

    ->Fixed an issue with the Paragraph field validation when a max character limit is configured and the value contains multi-byte characters.
    ->Fixed an issue with the Paragraph field validation when a max character limit is not configured.

    Are the ones relevant to this plugin?

    Anyone else suffering this issue? Any help would be appreciated.

    Cheers

    Darren

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

    (@ovann86)

    Hey,

    First, thanks for the detailed post.

    Fortunately I had an older copy of GF, so I was able to compare the difference and I found a new php function for the ‘paragraph’ field that checks the length of the field for validation (previously to this I think it was not done server-side).

    The issue I can see is that it counts spaces, where as I’ve setup CKEditor to NOT count spaces (I did this because it was the way the text counter tool worked).

    public function validate( $value, $form ) {
    		if ( ! is_numeric( $this->maxLength ) ) {
    			return;
    		}
    
    		$value = strip_tags( $value );
    		if ( GFCommon::safe_strlen( $value ) > $this->maxLength ) {
    			$this->failed_validation  = true;
    			$this->validation_message = empty( $this->errorMessage ) ? esc_html__( 'The text entered exceeds the maximum number of characters.', 'gravityforms' ) : $this->errorMessage;
    		}
    	}

    I’m still thinking through the options, but perhaps we can override this function to not count spaces? I could also look at the counter tool to make it count spaces so it’s more like the new (new) native WYSIWYG.

    Plugin Author ovann86

    (@ovann86)

    OK, I think I’ve worked out a way to fix this.

    I’m keen to get a fix pushed out because there’s the risk that information users provide in a form is lost — but I would prefer if you could test the patch first.

    Would you mind replacing the contents of gf_wysiwyg_ckeditor_plugin.php

    with this paste http://pastebin.com/K2vV5UDg

    It introduces ckeditor_dont_count_spaces()

    int3rc3ptor

    (@int3rc3ptor)

    Hi,

    Thanks for an equally detailed reply. Happy to test and will feed back here

    Best regards

    Darren

    int3rc3ptor

    (@int3rc3ptor)

    That patch worked fine for me, did a couple tests, went up to 2000 fine, got the expected message when trying to apply more than 2000 and can see all the text for the test posts being creating off the back of the submissions in the DB and WP Admin.

    Many thanks for jumping onto this very quickly, it’s a great little plugin and works really well with our setup, so thank you again for your help

    Best regards

    Darren

    Plugin Author ovann86

    (@ovann86)

    Thanks for the test, I’ll push out the update shortly. It’ll be the only change in this update.

    Yes- I’m a big fan of CKEditor. I think it’s a brilliant WYSIWYG, handles pasting from word so well (which is usually a nightmare), has great accessibility for assistive technology users, and many many addons for adding functionality.

    Now that Gravity Forms has a native WYSIWYG I’ve wondered if I should drop this plugin or transition it to the native one … but at this stage I don’t think I will. Unlike CKEditor, I find the native WYSIWYG (TinyMCE) basic and clunky.

    Good feedback thanks, it’s good to know it’s out there and being used.

    int3rc3ptor

    (@int3rc3ptor)

    I must admit it suits our needs at the moment perfectly, so unless you have a burning desire to do so, sticking with CKEditor might be the way to go for the time being. Thanks again!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Character Count issue with latest version of Gravity Forms’ is closed to new replies.