单选按钮未从laravel中的数据库中检索旧值


Radio button not retrieving old values from database in laravel

嗨,我的应用程序使用laravel框架,我有单选按钮,即wdv&slm相应的值被保存在数据库中,但我在编辑表单时无法检索保存的值。我尝试了不同的解决方案,但无法破解,我知道我做错了什么,请指导我解决这个问题。。

我的edit.blade.php

<!-- Depreciation Type -->
            <div class="form-group {{ $errors->has('depreciation_type') ? ' has-error' : '' }}">
                <label for="depreciation_type" class="col-md-3 control-label depreciationlabel">@lang('admin/assetdetails/form.depreciation')</label>
                    <div class="controls col-md-7">
                        {{ Form::radio('depreciation_type', 'wdv', Input::old('depreciation_type', $assetdetail->depreciation_type), array('id'=>'wdv', 'class'=>'wdvbutton')) }}
                        <label for="wdv" class="col-md-3 control-label wdvlabel">@lang('admin/assetdetails/form.wdv')</label>
                        {{ Form::radio('depreciation_type', 'slm', Input::old('depreciation_type', $assetdetail->depreciation_type), array('id'=>'slm','class'=>'wdvbutton')) }}
                        <label for="slm" class="col-md-3 control-label slmlabel">@lang('admin/assetdetails/form.slm')</label></br>
                        {{ $errors->first('depreciation_type', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
                    </div>
            </div>

控制器文件

public function getEdit($assetdetailId = null)
    {
        // Check if the location exists
        if (is_null($assetdetail = Assetdetail::find($assetdetailId)))
        {
            // Redirect to the blogs management page
            return Redirect::to('admin/settings/assetdetails')->with('error', Lang::get('admin/assetdetails/message.does_not_exist'));
        }
        $location_list = array('' => '') + Location::lists('name', 'id');
        $assettype_list = array('' => '') + Assettype::lists('asset_type', 'id');
        // Show the page
        //$location_options = array('' => 'Top Level') + Location::lists('name', 'id');
        $assetdetail_options = array('' => 'Top Level') + DB::table('asset_details')->where('id', '!=', $assetdetailId)->lists('asset_number', 'id');
        return View::make('backend/assetdetails/edit', compact('assetdetail'))->with('assetdetail_options',$assetdetail_options)->with('location_list',$location_list)->with('assettype_list',$assettype_list);
    }

    /**
     * Location update form processing page.
     *
     * @param  int  $locationId
     * @return Redirect
     */
    public function postEdit($assetdetailId = null)
    {
        // Check if the location exists
        if (is_null($assetdetail = Assetdetail::find($assetdetailId)))
        {
            // Redirect to the blogs management page
            return Redirect::to('admin/settings/assetdetails')->with('error', Lang::get('admin/assetdetails/message.does_not_exist'));
        }

        // get the POST data
        $new = Input::all();

        // attempt validation
        if ($assetdetail->validate($new))
        {
            // Update the location data
            $assetdetail ->asset_number             = e(Input::get('asset_number'));
            $assetdetail ->location_id              = e(Input::get('location_id'));
            $assetdetail ->assign_to                = e(Input::get('assign_to'));
            $assetdetail ->asset_type_id            = e(Input::get('asset_type_id'));
            $assetdetail ->nesd                     = e(Input::get('nesd'));
            $assetdetail ->active                   = e(Input::get('active'));
            $assetdetail ->shift                    = e(Input::get('shift'));
            $assetdetail ->supplier_name            = e(Input::get('supplier_name'));
            $assetdetail ->description              = e(Input::get('description'));
            $assetdetail ->dateof_purchase          = e(Input::get('dateof_purchase'));
            $assetdetail ->label_number             = e(Input::get('label_number'));
            $assetdetail ->purchase_price           = e(Input::get('purchase_price'));
            $assetdetail ->dateof_disposed          = e(Input::get('dateof_disposed'));
            $assetdetail ->depreciation_type        = e(Input::get('depreciation_type'));
            $assetdetail ->salvage_value            = e(Input::get('salvage_value'));
            $assetdetail ->asset_life               = e(Input::get('asset_life'));


            // Was the asset created?
            if($assetdetail->save())
            {
                // Redirect to the saved location page
                return Redirect::to("admin/settings/assetdetails/$assetdetailId/edit")->with('success', Lang::get('admin/assetdetails/message.update.success'));
            }
        }
        else
        {
            // failure
            $errors = $assetdetail->errors();
            return Redirect::back()->withInput()->withErrors($errors);
        }
        // Redirect to the location management page
        return Redirect::to("admin/settings/assetdetails/$assetdetailId/edit")->with('error', Lang::get('admin/assetdetails/message.update.error'));
    }

注意:我使用varchar作为我的数据类型,将数据库中的单选按钮值保存为wdv&slm

我试过

{{ Form::radio('depriciation_type', 'wdv', (Input::old('depriciation_type') == 'wdv'), array('id'=>'wdv', 'class'=>'radio')) }}
{{ Form::radio('depriciation_type', 'slm', (Input::old('depriciation_type') == 'slm'), array('id'=>'slm', 'class'=>'radio')) }}

我也试过

<input type="radio" name="type" value="wdv" class="radio" id="wdv" <?php if(Input::old('type')== "wdv") { echo 'checked="checked"'; } ?> >
<input type="radio" name="type" value="slm" class="radio" id="slm" <?php if(Input::old('type')== "slm") { echo 'checked="checked"'; } ?> >

我需要在路由文件中添加任何内容吗。

请帮我解决这个问题。。提前谢谢。

我自己找到了答案,这就是我所做的

{{ Form::radio('depreciation_type', 'wdv', Input::old('depreciation_type', $assetdetail->depreciation_type == 'wdv' ), array('id'=>'wdv', 'class'=>'wdvbutton')) }}
{{ Form::radio('depreciation_type', 'slm', Input::old('depreciation_type', $assetdetail->depreciation_type == 'slm' ), array('id'=>'slm', 'class'=>'slmbutton')) }}