Welcome Guest, Not a member yet? Register   Sign In
Form value repopulate
#2

(05-24-2022, 11:49 PM)vinyl Wrote: For a form I am working on I am trying to repopulate the fields after a submit and validation detected issues.
No matter what I try, it does not seem to work. 
My controller looks like this:

Code:
public function index()
    {
        helper(['form', 'url']);
        if (!$this->validate([

            'naam' => 'required'
         
        ])) {         
            echo view('form', [
                'validation' => $this->validator,
            ]);
        } else {
            echo "success!";
        }
    }

The view looks like this:
Code:
$attributes = ['class' => 'needs-validation', 'id' => 'form'];
echo form_open('public', $attributes);

      <div class="mb-3">
        <div class="row">
          <div class="col-12 col-md-6">
            <label for="Naam" class="form-label">Je naam</label>
            <input type="text" id="naam" name="naam" class="form-control <?php if ($validation->hasError('naam')) { echo "is-invalid"; } ?>" value="<?= set_value('naam') ?>">
          </div>
        </div>
      </div> 

If I look at the examples in de docs this should be sufficient to repopulate a form but it stays blank. Any ideas?

In the manual for CI 4 there is no mention of the repopulate option anymore under the validation library but I see the options are now listed under the forms section. Even in the examples there is no mention of this option, nor is it under the upgrade page (Upgrade Validations — CodeIgniter 4.1.9 documentation). Is this ommited or does it need to be implemented in a different way? I would be noteworthy to mention this on a upgrade page.

have you tried 
PHP Code:
value="<?= old('email') ?>" give it a shot and lemme know 
Reply


Messages In This Thread
Form value repopulate - by vinyl - 05-24-2022, 11:49 PM
RE: Form value repopulate - by SubrataJ - 05-25-2022, 09:21 PM
RE: Form value repopulate - by ikesela - 05-25-2022, 11:45 PM
RE: Form value repopulate - by InsiteFX - 05-26-2022, 12:52 AM
RE: Form value repopulate - by vinyl - 05-26-2022, 09:48 AM
RE: Form value repopulate - by kenjis - 05-27-2022, 06:59 PM
RE: Form value repopulate - by vinyl - 05-30-2022, 02:26 AM
RE: Form value repopulate - by tassman - 07-27-2022, 12:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB