public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $choices = array('a' => 'You are attending', 'm' => 'You are or might be attending', 'w' => 'You are or might be attending, or you watch the event');
     $builder->add('email_upcoming_events', 'choice', array('label' => 'Notify you of upcoming events', 'required' => true, 'choices' => $choices, 'expanded' => true));
     $builder->add("email_upcoming_events_days_notice", "number", array('required' => true, 'precision' => 0, 'label' => 'For upcoming events, how many days notice do you want?'));
     $repo = new \repositories\UserNotificationPreferenceRepository();
     foreach ($this->preferences as $key => $preference) {
         $userPref = $repo->load($this->user, $preference->getUserNotificationPreferenceExtensionID(), $preference->getUserNotificationPreferenceType());
         $builder->add($key, "checkbox", array('required' => false, 'label' => $preference->getLabel(), 'mapped' => false, 'data' => $userPref->getIsEmail()));
     }
 }
 function testSetThenGet()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $prefRepo = new UserNotificationPreferenceRepository();
     ### Set
     $prefRepo->editEmailPreference($user, 'org.openacalendar', 'WatchPrompt', true);
     ### Test
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchPrompt');
     $this->assertEquals(true, $pref->getIsEmail());
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchNotify');
     $this->assertEquals(true, $pref->getIsEmail());
     ### Set
     $prefRepo->editEmailPreference($user, 'org.openacalendar', 'WatchPrompt', false);
     ### Test
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchPrompt');
     $this->assertEquals(false, $pref->getIsEmail());
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchNotify');
     $this->assertEquals(true, $pref->getIsEmail());
     ### Set
     $prefRepo->editEmailPreference($user, 'org.openacalendar', 'WatchNotify', false);
     ### Test
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchPrompt');
     $this->assertEquals(false, $pref->getIsEmail());
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchNotify');
     $this->assertEquals(false, $pref->getIsEmail());
     ### Set
     $prefRepo->editEmailPreference($user, 'org.openacalendar', 'WatchPrompt', true);
     ### Test
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchPrompt');
     $this->assertEquals(true, $pref->getIsEmail());
     $pref = $prefRepo->load($user, 'org.openacalendar', 'WatchNotify');
     $this->assertEquals(false, $pref->getIsEmail());
 }