0

I created a custom widget according to Widget API and it seems to work until I make changes. The save button is not triggered, this problem is only affecting this new widget.

Ps. The custom widget is also part of a dynamic_sidebar but every other widget works fine.

The button is enabled but not triggered.

Save Button issue

Edit. Widget code

2
  • 2
    Can you please here your custom widget code. so I can help you. Commented Apr 30, 2019 at 11:57
  • Sure, codeshare.io/2jJLDK
    – laviku
    Commented Apr 30, 2019 at 12:01

1 Answer 1

1

I have checked code of codeshare.io/2jJLDK and found the issue. Please follow below instructions for fix this issue.

In the form function, you have used input type as "url" for Link and as per rule of input type "url", it can't take "#" so you must use actual url with http/https like https://www.google.com/ for saving/updating widget link data.*


If you want to save/update widget link data with "#" then you need to change input type as "text" like below

From:

<input type="url" name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" class="widefat" value="<?php echo esc_attr( $link ) ?>">

To:

<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'link' ) ); ?>" class="widefat" value="<?php echo esc_attr( $link ) ?>">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.