Cakephp 模型别名有效,但视图不显示

发布于 2024-12-07 14:48:28 字数 929 浏览 1 评论 0原文

我阅读了您关于 cakephp 模型别名 的答案,并且我在我的模型上做了你写的,我调试了我的视图,它列出了我想要的内容,但它没有在相应字段上显示列表,你知道出了什么问题吗?

我的模型:

'ResponsavelManutencao' => array(
      'className' => 'Operador',
      'foreignKey' => 'responsavel_manutencao_id',
      'conditions' => '',
      'fields' => '',
      'order' => '')

我的控制器:

function add(
      $responsavelManutencao = $this->Dentista->ResponsavelManutencao->find('list');
      $this->set(compact('responsavelManutencao'));)

我的观点:

echo $this->Form->input('responsavel_relacionamento_id', array(
      'class' => 'field text small', 'empty' => '',
      'after' => 'Funcionario responsavel por manter o contato comercial.')); 
      debug($responsavelRelacionamento);

I read your answer about cakephp model alias and I did on my model what you wrote, I debuged my view and it list what I want, but it doesn't show the list on the respective field, do you have any idea what is wrong?

My model:

'ResponsavelManutencao' => array(
      'className' => 'Operador',
      'foreignKey' => 'responsavel_manutencao_id',
      'conditions' => '',
      'fields' => '',
      'order' => '')

My controller:

function add(
      $responsavelManutencao = $this->Dentista->ResponsavelManutencao->find('list');
      $this->set(compact('responsavelManutencao'));)

My view:

echo $this->Form->input('responsavel_relacionamento_id', array(
      'class' => 'field text small', 'empty' => '',
      'after' => 'Funcionario responsavel por manter o contato comercial.')); 
      debug($responsavelRelacionamento);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我纯我任性 2024-12-14 14:48:28

我猜你的语言的 CakePHP 单数/复数规则有问题。我认为您应该将视图变量命名为“responsavelRelacionamentos”才能正常工作。

然而,在没有变形魔法的情况下实现目标的最安全方法是:

echo $this->Form->input('responsavel_relacionamento_id', array(
    'options' => $responsavelRelacionamento,
    'class' => 'field text small', 'empty' => '',
    'after' => 'Funcionario responsavel por manter o contato comercial.'
)); 

I guess there is something wrong with the CakePHP singular/plural rules for your language. I think you should name your view variable "responsavelRelacionamentos" for it to work.

However, the safest way to accomplish your goal without inflection magic would be:

echo $this->Form->input('responsavel_relacionamento_id', array(
    'options' => $responsavelRelacionamento,
    'class' => 'field text small', 'empty' => '',
    'after' => 'Funcionario responsavel por manter o contato comercial.'
)); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文