WP_Widget::form( array $instance )
Outputs the settings update form.
Description Description
Parameters Parameters
- $instance
-
(array) (Required) Current settings.
Return Return
(string) Default return is 'noform'.
Source Source
File: wp-includes/class-wp-widget.php
public function form( $instance ) {
echo '<p class="no-options-widget">' . __( 'There are no options for this widget.' ) . '</p>';
return 'noform';
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Ever wonder why your IDE complains that your
form()method isn’t returning a value?WP_Widget::formreturns'noform'by default, so technically any class that extendsWP_Widgetshould also return a string. The vast majority of widgets don’t have anyreturnstatement, so they implicitly returnNULL.wp-admin/widgets.phpchecks the return value when rendering the widget’s form, and if the value is'noform', then it hides theSavebutton. If the value is anything else, it shows theSavebutton.So, you should technically return a string inside your
form()method, even if it’s just an empty string, but theSavebutton will still show up even if you don’t.