Support » Plugins » Hacks » Select fields and widgets

  • not going to be the easiest thing to help me with, but i need a second set of eyes. Any ideas why this custom widget i have made is saving everything besides the <select> field when I save the widget? here is the code: You probably want to look at lines starting at 60.

    BTW, created markup looks like so:

    Seems all input fields like text, title, url, etc, are saved correctly, but the value from the select field is not. Any suggestions? I would really appreciate any help. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Not too familar with widget development, but nevertheless: I’d trace how this data is being saved. In your plugin, do this:

    if ($_POST) {
        echo "<pre>" . print_r($_POST, true) . "</pre>";

    That’ll let you see if the form values are coming back okay (I’m presuming it’s a POST form).

    If that’s good then you’ll need to look at the save code (presumably this is part of WP?). I’d put your whole site in version control, and then you can easily add echo/exit/debug statements around WP to your hearts content (and it’s easy to revert).

    When generating the name attribute for your select item you use $this->get_field_id( 'campus ). Instead it has to be $this->get_field_name( 'campus' ) like with the other fields 🙂

    great catch! I knew an extra set of eyes would help me spot such a simple mistake. Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Select fields and widgets’ is closed to new replies.