PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Prepopulated post_category selector and isSelected fails

  1. bartv2
    Member

    I've prepopulated a post_category field with a bunch of values that I retrieved from the database. Unlike regular drop-down fields, a category drop-down is a real key-value pair (category-id => category name).

    The get_select_choices method in common.php doesn't seem to handle this correctly: the way it is set up now it'll ignore the isSelected value is there is an incoming value (which works, but confused the heck out of me as I was trying to insert an isSelected field).

    Next, the code checks to see if the incoming value matches the option label:

    $selected = ($value == $choice["text"]) ? "selected='selected'" : "";

    For common drop-down fields this is fine as the value is equal to the text, but for categories this fails as the option's value is different from the label. I believe the code should read:

    '$selected = ($value == $choice["value"]) ? "selected='selected'" : "";

    It works for me. Can you confirm my solution and if so, include it in the next release?

    Thanks!

    Bart

    Posted 14 years ago on Thursday February 25, 2010 | Permalink
  2. Thanks Bart, i'll have our lead developer check this out and post a response shortly.

    Posted 14 years ago on Thursday February 25, 2010 | Permalink
  3. Your solution is fine, we will get this added in the next release so that going forward it takes the value into account.

    Posted 14 years ago on Thursday February 25, 2010 | Permalink

This topic has been resolved and has been closed to new replies.