CodeIgniter Forums
update form validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: update form validation (/showthread.php?tid=76574)



update form validation - rafapirapo - 05-27-2020

hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>


RE: update form validation - nmaa3003 - 05-28-2020

i want to help, but cant understand a damn u talking about.
your code also messed up for me to read.. organize it


RE: update form validation - wdeda - 05-28-2020

(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.


RE: update form validation - cukikt0302 - 05-28-2020

Hi
I think u need this:

https://codeigniter.com/user_guide/helpers/form_helper.html#set_select


RE: update form validation - rafapirapo - 05-28-2020

(05-28-2020, 08:02 AM)wdeda Boa tarde, segue a imagem tentando explicar Wrote:
(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.



RE: update form validation - wdeda - 05-28-2020

(05-28-2020, 01:52 PM)rafapirapo Wrote:
(05-28-2020, 08:02 AM)wdeda Boa tarde, segue a imagem tentando explicar Wrote:
(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.

Entendi todo o processo mas tenho uma questão: se ele deixa de preencher um campo obrigatório nenhuma atualização é efetuada, o SIM não é atualizado, não faria sentido existir a validação.


RE: update form validation - rafapirapo - 05-28-2020

(05-28-2020, 04:59 PM)wdeda Mas o select Option perde  a alteração feita pelo usuário. Nos inputs funciona perfeitamente, por exemplo  caso altere o nome para RAFAEL e deixar o login sem preenchimento, o nome volta como RAFAEL e não como RAFAEL SILVA. Eu queria que isso ocorresse com o select option. Wrote:
(05-28-2020, 01:52 PM)rafapirapo Wrote:
(05-28-2020, 08:02 AM)wdeda Boa tarde, segue a imagem tentando explicar Wrote:
(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.

Entendi todo o processo mas tenho uma questão: se ele deixa de preencher um campo obrigatório nenhuma atualização é efetuada, o SIM não é atualizado, não faria sentido existir a validação.



RE: update form validation - InsiteFX - 05-29-2020

When displaying CodeIgniter code in the forums use the code tags in the editor.

remove the space in the tags:

[ code] your code [ /code]

There are buttons for this in the forum editor.


RE: update form validation - wdeda - 05-29-2020

(05-28-2020, 04:59 PM)wdeda Wrote:
(05-28-2020, 01:52 PM)rafapirapo Wrote:
(05-28-2020, 08:02 AM)wdeda Boa tarde, segue a imagem tentando explicar Wrote:
(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.

Entendi todo o processo mas tenho uma questão: se ele deixa de preencher um campo obrigatório nenhuma atualização é efetuada, o SIM não é atualizado, não faria sentido existir a validação.

Rafael, a questão é que o campo SIM/NÃO é um drop/down, ou seja, quando o usuário chega a essa tela o status dele é não quando ele deixa de preencher o campo obrigatório ele volta ao estado normal, eu entedo o que você deseja. Por exemplo em um formulário sem drop/down os campos já preenchidos quando uma campo obrigatório não é preenchido, são exibidos com as informações registradas pelo usuário. Pode ser que haja algum tipo de "macete" que permita isso, vou colocar em inglês e ver se alguém conhece.

The image attached by @rafapirapo is duplicated, before and after. It is a form for changing user data. The form header is: "ALTERAR DADOS DO USUÁRIO". Below, on the right, there is a drop/down, "ATIVO - STATUS" and option 1 is "NÃO(no)". Still below, but now on the left, there is a field "USUÁRIO (User)" that is required, he would like that if the user chose the drop/down 2 "SIM(yes)" and did not fill in the required field when the form was displayed again to the user for fill in the required field, option 2, already marked by the user, "SIM(yes)", was kept.

His code
Model
Code:
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>  $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();

Controller:
Code:
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }

View:
Code:
<div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>



RE: update form validation [RESOLVED] - rafapirapo - 05-29-2020

Situação resolvida, coloquei o código PHP que faz a verificação e aponta o selected para o value correto no inicio da página. Antes estava logo acima do select.
Agradeço a atenção
(05-28-2020, 04:59 PM)wdeda Wrote:
(05-28-2020, 01:52 PM)rafapirapo Wrote:
(05-28-2020, 08:02 AM)wdeda Boa tarde, segue a imagem tentando explicar Wrote:
(05-27-2020, 06:57 PM)rafapirapo Wrote: hello, I have a problem with select options, it is necessary that when entering the edit page, bring the selected item as it appears in the database, when the post is executed if there are validations errors return to the edit page but with the select option selected according to last choice of the user, example when entering the database the option FORD the user changes to VW and submits the form and does not pass the validation of other fields must return to the edition form with the selected VW option.---- MODEL
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>   $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();
    }----CONTROLE
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }
          ?>
          <div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>

I apologize, but I will use Portuguese to better understand what is going on, I have a slight idea.

Se entendi bem, você deseja que um usuário após não entrar com um campo obrigatório a tela mostrada seja a mesma em que este campo não é preenchido. Isso não é possível, mas, para tanto, basta o usuário retornar no navegador que a tela será exibida.

Com o código mostrado por você nada irá acontecer, pois não existe uma série de informaçãoes necessárias, não existe um formulário sequer para isso.

Por favor, não se ofenda, mas me permita lhe sugerir a leitura do manual https://codeigniter.com/user_guide/tutorial/news_section.html ou, acompanhar uma sequência de 4 vídeos no Youtube, em português, onde você irá encontrar exatamente o que deseja: https://www.youtube.com/watch?v=6e3KG8NrHOM

Boa sorte.

Entendi todo o processo mas tenho uma questão: se ele deixa de preencher um campo obrigatório nenhuma atualização é efetuada, o SIM não é atualizado, não faria sentido existir a validação.

Rafael, a questão é que o campo SIM/NÃO é um drop/down, ou seja, quando o usuário chega a essa tela o status dele é não quando ele deixa de preencher o campo obrigatório ele volta ao estado normal, eu entedo o que você deseja. Por exemplo em um formulário sem drop/down os campos já preenchidos quando uma campo obrigatório não é preenchido, são exibidos com as informações registradas pelo usuário. Pode ser que haja algum tipo de "macete" que permita isso, vou colocar em inglês e ver se alguém conhece.

The image attached by @rafapirapo is duplicated, before and after. It is a form for changing user data. The form header is: "ALTERAR DADOS DO USUÁRIO". Below, on the right, there is a drop/down, "ATIVO - STATUS" and option 1 is "NÃO(no)". Still below, but now on the left, there is a field "USUÁRIO (User)" that is required, he would like that if the user chose the drop/down 2 "SIM(yes)" and did not fill in the required field when the form was displayed again to the user for fill in the required field, option 2, already marked by the user, "SIM(yes)", was kept.

His code
Model
Code:
public function updaterecord($data)
    {
        $id = $data['UsuID'];
        return $this->where('UsuID', $id)
            ->set([
                'UsuLogin' =>  $data['UsuLogin'],
                'UsuNome' =>  $data['UsuNome'],
                'UsuCPF' =>    $data['UsuCPF'],
                'UsuNivel' =>  $data['UsuNivel'],
                'UsuStatus' => $data['UsuStatus']
            ])
            ->update();

Controller:
Code:
public function update($id = NULL)
    {
        if ($this->request->getMethod() === 'post') {
            $data = $this->request->getPost();
            if($this->usuarioModel->updaterecord($data) == false){
                $session = session();
                $msgerrors = ['errors' => $this->usuarioModel->errors()];
                $session->setFlashdata($msgerrors, $data);
                return redirect()->back()->withInput();
            }
        }else{
            $data['dados'] = $this->usuarioModel->showid($id);
            echo view('includes/header');
            echo view('includes/menu');
            echo view('usuario_editar', $data);
            echo view('includes/footer');        }----VIEW<?php
              $v1=''; $v2 = '';
              if($dados[0]['UsuStatus'] === "0" || old('UsuStatus') === "0"){
                $v1 = 'selected';
              }else{
                $v1='';
              }
              if($dados[0]['UsuStatus'] === "1"  || old('UsuStatus') === "1"){
                $v2 = 'selected';
              }else{
                $v2='';
              }

View:
Code:
<div class="form-group col-md-3 cb">
            <label for="cbusustatus">Ativo - Status</label>
            <select class="form-control" id="cbusustatus" name="UsuStatus">
              <option value="0"  <?php echo $v1 ?>>0-Sim </option>
              <option value="1" <?php echo $v2 ?>>1-Não </option>
            </select>
          </div>
[/quote]