Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 cakephp 2 中,有什么区别:
echo $this->Form->input('User.username');
和
echo $this->Form->input('username');
??
谢谢。
取决于你的形式
如果你使用this->Form->create('User')没有区别,因为它属于同一个模型,但如果你保存相关数据,那么你需要使用描述性版本来告诉蛋糕该字段属于哪个模型。
this->Form->create('User')
第一个明确定义用户模型的用户名字段,而第二个回退到控制器的默认模型,如果您在 UserController 中,用户是什么,但如果您的控制器是 PostsController,您的 Post 模型也应该有一个用户名字段,例如保存表格数据。