Welcome Guest, Not a member yet? Register   Sign In
accessing Class Method
#1

[eluser]SDSL[/eluser]
hello,
i've class that is loaded into the controller

models/wizard.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');



/**

* Wizard Model for handeling Signup process

*/



class Wizard extends Model

{



  public  $current_step = '';

  



  

  public function __construct()

    {

    parent::Model();

    $this->current_step = $this->_current_step();

  }  

  public function steps($step=null)

  {    

    $steps = array(

      '0'=>'first',

      '1'=>'personal',

      '2'=>'account',

      '3'=>'validate');

      

    if(is_null($step)){

      return $steps[0];

    }else{

      if(is_numeric($step)){        

        return $this->steps();

      }elseif(is_string($step) && !is_numeric($step)){

        $k = array_search($step, $steps);        

        return $steps[$k];

      }

    }

  }

  

  public function _current_step()

  {

    if($this->current_step){

      return $this->current_step;

    }else{      

      return $this->steps(0);

    }

  }

  

  public function next_step()

  {

    $next_step = $this->current_step + 1;    

    $this->current_step = $this->steps($next_step);    

  }

  

  public function prev_step()

  {

    $prev_step = $this->current_step - 1;    

    $this->current_step = $this->steps($prev_step);    

  }

  

  public function is_first_step(){    

    return $this->current_step == $this->steps(0);

  }

  

  public function is_last_step(){

    $count = count($this->steps());

    $last = $count-1;    

    return $this->current_step == $this->steps($last);

  }

  

}

in controller

Code:
$this->wizard->steps();
prints the steps array
and
Code:
$this->wizard->_current_step();
echos the current_step value

WHY wouldn't
Code:
$this->wizard->current_step;
work ????
#2

[eluser]SDSL[/eluser]
i ended moving the methods into the controller, it's not elegant but it should save me expected headache




Theme © iAndrew 2016 - Forum software by © MyBB