Reputation: 935
i have this page that loads a specific record based on the id and this form will allow the user to modify the record here is my code
@foreach($modData as $list)
@endforeach
<div class="gtdwn">
<h5>Edit Details</h5>
<h6>File Information</h6>
{{ Form::open(array('method' => 'PUT', 'action' => array('sample@savemodfile', $list->subcategoryid, $list->fileid))) }}
<h6>Filename : </h6>
{{ Form::text('eFile', $list->filename ) }}
<span>File type : {{ $list->filetype }} </span>
@if($list->filetype == 'ppt' || $list->filetype == 'pptx')
<img src="{{ asset('img/ico/pptico.PNG') }}" class="imgico">
@elseif($list->filetype == 'doc' || $list->filetype == 'docx')
<img src="{{ asset('img/ico/wordico.PNG') }}" class="imgico">
@elseif($list->filetype == 'pdf')
<img src="{{ asset('img/ico/pdfico.PNG') }}" class="imgico">
@elseif($list->filetype == 'xls' || $list->filetype == 'xlsx')
<img src="{{ asset('img/ico/excelico.PNG') }}" class="imgico">
@elseif($list->filetype == 'txt')
<img src="{{ asset('img/ico/txtico.PNG') }}" class="imgico">
@elseif($list->filetype == 'csv')
<img src="{{ asset('img/ico/csvico.PNG') }}" class="imgico">
@endif
<h6>Size : {{ $list->filesize }} </h6>
@if($list->confidential == 'true')
{{ Form::checkbox('conf', 'true', true , array('id' => 'test5')) }}
<label for="test5">confidential</label>
@else
{{ Form::checkbox('conf', 'true', null , array('id' => 'test5')) }}
<label for="test5">confidential</label>
@endif
{{Form::select('sCategory',[ $list->subcategoryid =>'CURRENT CATEGORY : ' . $list->subcategoryname . ' | ' . $list->maincategoryname] + $cats )}}
{{ Form::submit('save', array('class' => 'btn btn-primary defcolor')) }}
{{ Form::close()}}
<br>
</div>
so far it properly loads the data when the user clicked the submit button it would go to this route
Route::put('modifyFile/{sid}/{id}' , array('as' => 'modfyFilesave', 'uses' => 'sample@savemodfile'));
i also have supplied the id
in my form already but when it reaches my controller when i do validation it can't read the data in it
public function savemodfile($scid , $id)
{
$some = Input::get('eFile');
dd($some);
$rules = array(
'eFile' => 'required|min:2|max:250|unique:nsa_fileuploads,filename'
);
$messages = array(
'eFile.required' => 'Please provide a filename.',
'eFile.min' => 'Filename should have atleast 2 characters.',
'eFile.max' => 'Filename can only have maximum of 250 characters.',
'eFile.unique' => 'Filename already exist.'
);
$validator = Validator::make(Input::all(), $rules , $messages);
if ($validator->fails())
{
dd('some errors');
}
else
{
dd('okay');
}
}
i tried dumping the value from the Form::text('eFile',$list->filename)
and i got the value from the view but when i use it inside the validator, even only the required, it always fails. any idea what is wrong with my code? thanks in advance!
Upvotes: 0
Views: 277
Reputation: 1573
You provide a controller method as your action in your from. Does that actually work? Try changing this:
'action' => array('sample@savemodfile', $list->subcategoryid, $list->fileid)
To
'action' => route('modfyFilesave',
array('sid' => $list->subcategoryid, 'id' => $list->fileid))
Upvotes: 1
Reputation: 608
Replace your form with this
{{ Form::open(array('files'=>true, 'action' => array('sample@savemodfile', $list->subcategoryid, $list->fileid))) }}
in your form add this line 'files' => true
Hope this code will help you!!
Upvotes: 1