/**
  * @param Application $app
  * @param Request $request
  *
  * @return Response
  */
 public function add(Application $app, Request $request)
 {
     $form = $app->createForm(new MemberType());
     if ($request->isMethod('post')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $data = $form->getData();
             $member = new Member($data['username'], $data['password'], new Address('Canada', 'Ontario', $data['city'], $data['postal_code']), $data['date_of_birth'], Limits::all()[$data['limits']], new Height($data['height']), new Weight($data['weight']), BodyType::all()[$data['body_type']], Ethnicity::all()[$data['ethnicity']], new Email($data['email']));
             $app['repository.members']->add($member);
             $app->flashSuccess(sprintf('Member "%s" was successfully added', $member->getUsername()));
             return $app->redirect($app->path('manage.members'));
         }
     }
     return $app->render('manage/members.add.twig', ['form' => $form->createView()]);
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('username', 'text', ['constraints' => new NotBlank()])->add('password', 'text', ['constraints' => new NotBlank()])->add('city', 'text', ['constraints' => new NotBlank()])->add('postal_code', 'text', ['constraints' => [new NotBlank(), new Length(['min' => 6, 'max' => 7])]])->add('date_of_birth', 'birthday', ['widget' => 'single_text', 'constraints' => [new NotBlank(), new Date(), new Age(['min' => 18])]])->add('limits', 'choice', ['constraints' => new NotBlank(), 'choices' => Limits::all()])->add('height', 'text', ['constraints' => [new NotBlank(), new Length(['max' => 5])]])->add('weight', 'text', ['constraints' => [new NotBlank(), new Length(['max' => 7])]])->add('body_type', 'choice', ['constraints' => new NotBlank(), 'choices' => BodyType::all()])->add('ethnicity', 'choice', ['constraints' => new NotBlank(), 'choices' => Ethnicity::all()])->add('email', 'email', ['constraints' => [new NotBlank(), new Email()]])->add('Add', 'submit');
 }