Select fields and widgets (4 posts)

  1. MACscr
    Posted 2 years ago #

    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: http://pastebin.com/UKYB13LY. You probably want to look at lines starting at 60.

    BTW, created markup looks like so: http://pastebin.com/SjESt0Mt

    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!

  2. halferdev
    Posted 2 years ago #

    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).

  3. Chris
    Posted 2 years ago #

    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 :)

  4. MACscr
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.