This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

dev.mnr.j20762
dev.mnr.j20762

I am having the error << Unknown "old" function. Did you mean "placeholder"? >> when I try to get old input values of my form.

My input field code at the front-end is like that:


    <div class="required form-group">
      <label for="name">Full name</label>
      <span class="input-wrapper">
          <input type="text"
                   name="name"
                   class=" form-control"
                   value="{{ old('name') }}"
            >
      </span>
    </div>

At the backend, when validator fails, I redirect the request like that:

if ($validator->fails()) {
            // The given data did not pass validation
            return Redirect::back()
            ->withInput()
            ->withErrors($validator);
}

Last updated

dev.mnr.j20762
dev.mnr.j20762

This is my solution ->

Instead of using old('name') I now use form_value('name') and it works.

http://stackoverflow.com/a/33778147/2122096

jc91715
jc91715

try this?

$this->controller->getTwig()->addFunction(
        new \Twig_SimpleFunction(
            'old', function () {
            return request()->old(func_get_arg(0));
        }
        )
    );
Mennax
Mennax

dev.mnr.j20762 said:

Instead of using old('name') I now use form_value('name') and it works.

http://stackoverflow.com/a/33778147/2122096

Thanks, it works!

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.