CodeIgniter select_value in form_dropdown

前端 未结 6 1818
-上瘾入骨i
-上瘾入骨i 2020-12-18 12:31

I have a dropdown field in my form and when I hit submit the form goes through validation and if an error happens, return all the value. This work expect for my dropdown meu

6条回答
  •  臣服心动
    2020-12-18 12:56

    CodeIgniter has set_checkbox() and set_radio() that you need to use instead of set_value()

    But set_checkbox and set_radio have some issues, and don't seem to be able to handle forms that are designed to handle BOTH create AND update forms.

    This is the fix. You can put this code in a helper or extend the form_validation class.

    
    
    $field))
        {
            // does it match the value we provided?
            if ($defaults->$field == $value)
            {
                // yes, so set the checkbox
                echo "checked='checked'"; // valid for both checkboxes and radio buttons
            }
        }
    }
    ?>
    

提交回复
热议问题