Skip to content

Docs: unclear usage of the old() global function #7677

@sammyskills

Description

@sammyskills

PHP Version

7.4

CodeIgniter4 Version

4.3.6

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

No response

What happened?

From the docs about the global old() function, there is this statement:

If you are using the form helper, this feature is built-in. You only need to use this function when not using the form helper.

If I understand correctly, the statement above means that if a developer is using the form helper, for example: form_open(), they do not need to use the old() function, as it is built-in.

Now I have a form, and I redirected back to the previous page using return redirect()->back()->withInput(), but the old values of the form are not retained when I don't use <?= old() ?> in the form value attribute.

Is this a mistake or is there a specific way to do this?

Steps to Reproduce

  1. Create a view, add some form element, for example:
<?= form_open() ?>

<input type="text" name="name" value="">

<input type="email" name="email" value="">

<?= form_close() ?>
  1. In your controller, just return back to the previous page, like so: return redirect()->back()->withInput();

Expected Output

It is either the documentation is misleading or incomplete.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationPull requests for documentation only

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions