• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
disable/hide button using condition in controller

#2
If you are not already using views, you should consider it, but here's a simple example how to pass data to view and then in view display different HTML, depending on values.

Controller:
PHP Code:
public function index()
{
    
// ...

    
$showRegistrationButtonfalse;

    
// data to pass to view
    
$data = [
        
'showRegistrationButton' => $showRegistrationButton,
        
'pageTitle' => 'My page title'
    
];

    
$this->load->view('myview'$data);


View file:
PHP Code:
<h1><?= $pageTitle ?></h1>
<?php if ($showRegistrationButton) : ?>
    <a href="<?= site_url('registration-controller'?>">Register</a>
<?php else: ?>
    <div>Already registered</div>
<?php endif ?>
Reply


Messages In This Thread
RE: disable/hide button using condition in controller - by Pertti - 07-10-2018, 11:33 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.