Outputs the settings update form.
Parameters
$instance
arrayrequired- The settings for the particular instance of the widget.
Source
public function form( $instance ) {
echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>';
return 'noform';
}
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
Ever wonder why your IDE complains that your
form()
method isn’t returning a value?WP_Widget::form
returns'noform'
by default, so technically any class that extendsWP_Widget
should also return a string. The vast majority of widgets don’t have anyreturn
statement, so they implicitly returnNULL
.wp-admin/widgets.php
checks the return value when rendering the widget’s form, and if the value is'noform'
, then it hides theSave
button. If the value is anything else, it shows theSave
button.So, you should technically return a string inside your
form()
method, even if it’s just an empty string, but theSave
button will still show up even if you don’t.