public function configure() { $friend_array = array(); $friends = FriendTable::getFriendsOfUid($this->uid); $count = 0; foreach ($friends as $friend) { $friend_array[$friend->getUid()] = $friend->getName(); $count++; } //echo $count; //die; $this->setWidgets(array('recipients' => new sfWidgetFormChoice(array('multiple' => true, 'choices' => $friend_array)), 'subject' => new sfWidgetFormInput(), 'message' => new sfWidgetFormInput())); $this->setValidators(array('recipients' => new sfValidatorString(array('required' => false)), 'subject' => new sfValidatorString(array('required' => false)), 'message' => new sfValidatorString(array('required' => false)))); $this->widgetSchema->setNameFormat('message[%s]'); }
public function executeNewMessage(sfWebRequest $request) { $friend_array = array(); if ($request->hasParameter('uid')) { $profile = Doctrine_Core::getTable('Profile')->findOneByUid($request->getParameter('uid')); $friend_array[$profile->uid] = $profile->name; } else { $friends = FriendTable::getFriendsOfUid($this->getUser()->getAttribute('id')); $count = 0; foreach ($friends as $friend) { $friend_array[$friend->getUid()] = $friend->getName(); $count++; } } $this->form = new MessageForm($this->getUser()->getAttribute('id')); $this->form->setWidget('recipients', new sfWidgetFormChoice(array('multiple' => true, 'choices' => $friend_array))); //$this->form->setDefault('recipients', 4); }
public function getFriends() { return FriendTable::getFriendsOfUid($this->uid); }