这是我的模型:
class Persona extends AppModel {
// This is just some arbitrary property I need to populate in the controller.
public $TipoPersona = '';
}
这是我的控制器中的动作功能:
public function details($id = null) {
// Just a typical load by id.
$this->Persona->id = $id;
$this->set('persona', $this->Persona->read());
// Can I do something like?
$this->Persona->TipoPersona = "Mafa Woogly";
}
如何$TipoPersona
在此处的“模型”中设置属性?我的意图是然后在视图中使用该属性,例如:
<tr>
<th>Tipo de Persona:</th>
<td><?php echo h($persona->TipoPersona); ?></td> // Or similar?
</tr>
有什么建议么?
这行得通,但感觉很不稳定并且不是强类型的。
public function details($id = null) {
$this->Persona->id = $id;
$this->set('persona', $this->Persona->read());
$this->set('tipoPersona', "Mafa woogly");
}
<tr>
<th>Tipo de Persona:</th>
<td><?php echo h($tipoPersona); ?></td>
</tr>