Ever wonder why your IDE complains that your widget’s form()
method isn’t returning a value?
WP_Widget::form
returns 'noform'
by default, so technically any class that extends WP_Widget
should also return a string. The vast majority of widgets don’t have any return
statement, so they implicitly return NULL
.
wp-admin/widgets.php
checks the return value when rendering the widget’s form, and if the value is 'noform'
, then it hides the Save
button. If the value is anything else, it shows the Save
button.
So, you should technically return a string inside your form()
method, even if it’s just an empty string, but the Save
button will still show up even if you don’t.
Can you / should you return ‘noform’, so you don’t see the Save button?
If you want to hide the
Save
button, then it’s definitely fine to return'noform'
:)