Last active
August 29, 2015 14:21
-
-
Save rochamarcelo/38a4352a08f844bb98dd to your computer and use it in GitHub Desktop.
Job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->Form->input( | |
'status', | |
['options' => $statuses] | |
); | |
echo $this->Statuses->getStatusText($entity['Job']['status']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Job extends AppModel | |
{ | |
public function getStatuses() | |
{ | |
return [ | |
1 => 'Aberta(o)', | |
2 => 'Fechada(o)', | |
3 => 'Cancelada(o)' | |
]; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JobController extends AppController | |
{ | |
public function add() | |
{ | |
$statuses = $this->Job->getStatuses(); | |
$this->set('statuses', $statuses); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class StatusesHelper extends Helper | |
{ | |
private $statuses = [ | |
1 => 'Aberta(o)', | |
2 => 'Fechada(o)', | |
3 => 'Cancelada(o)' | |
]; | |
public function __construct(View $View, $settings = array()) { | |
parent::__construct($View, $settings); | |
$statuses = $View->get('statuses'); | |
if ( !empty($statuses) ) { | |
$this->statuses = $statuses; | |
} | |
} | |
public function getStatuses() | |
{ | |
return $this->statuses; | |
} | |
public function getStatusText($statusCode) | |
{ | |
if ( isset($this->statuses[$statusCode]) ) { | |
return $this->statuses[$statusCode]; | |
} | |
return ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment