I am not sure if this is the correct behaviout.
In one of my controller methods -
PHP Code:
public function test() {
$data_post = $this->request->getPost();
if(!empty($data_post)) {
$validation = $this->validate(
['what' => 'required',],
['what' => ['required'=>'Please enter what is required']]);
if($validation == false) {
redirect()->back()->withInput();
exit;
} else {
//valid submission
}
}
$html = '<form method="post">
<input type="text" class="form-control" name="what" id="what" value="'.old('what').'" />
<button class="btn btn-success" type="submit">Submit</button>
</form>';
$html .= service('validation')->listErrors();
echo view('myview', ['html' => $html]);
}
It prints out the validation error message but old doesn't fill in the value in the input box.
However, if I just add
in this code above it works fine.
Is this how it it is supposed to work? Or perhaps I need to make a session call in the constructor of the controller so that session is available in all the methods?