cakephp - Error: userHelper could not be found in cakephp3.5.1 -
how fix issue
error: userhelper not found.
this search.ctp
inside element called in default.ctp
<?php echo $this->form->create(null, ['url' => ['controller' => 'users', 'action' => 'search']], array('type' => 'get')); ?> <?php echo $this->form->input('username'); ?> <?php echo $this->form->button('search', ['type' => 'submit']); ?>
below search controller
public function search() { $value = $this->request->getdata('username'); $results = $this->users->find('all', ['fields'=>[ 'users.username', 'users.email', 'users.id', 'users.age', 'users.address', 'users.gender' ], 'order' => 'users.id asc', 'conditions' => array(' username like' => "%".$value."%") ]); $this->set('user', $results); $this->set('_serialize', ['user']); }
search.ctp inside users
<?php use cake\orm\tableregistry; use cake\filesystem\folder; use app\controller\appcontroller; ?> <?php foreach ($user $users): ?> <?php echo $this->users->username;?> <?php endforeach;?>
what line inside loop? shouldn't be.
$this->users->username;
i'm not sure returning array or object in cakephp 3.
but, i'm sure should that,
$users->username;
or
$users['username'];
Comments
Post a Comment