开发者

fill custom form with object

开发者 https://www.devze.com 2023-03-04 21:35 出处:网络
i have a simple form: UserInfoForm(). when i first display the form to the user, i want it to be filled with data from a specific object of the User model.

i have a simple form: UserInfoForm(). when i first display the form to the user, i want it to be filled with data from a specific object of the User model. can anyone give 开发者_StackOverflowme a direction or an example? thanks!


Normally, you'd do it like this but it depends on how your UserInfoForm relates to the User object:

$user = Doctrine::getTable('User')->findOneById($user_id);
$this->form = new UserInfoForm($user);

Edit: I'm assuming you're using Doctrine.

0

精彩评论

暂无评论...
验证码 换一张
取 消