0

The stack trace seems to point to this in my entity

/**
 * @Assert\NotBlank()
 * @Assert\Type(type="numeric")
 * @Assert\GreaterThan(value=70)
 * @ORM\Column(type="decimal")
 */
public $start_weight;

The getter and setter for the start weight is as follows. Note that this was generated by the doctrine:generate:entities command.

/**
 * Set start_weight
 *
 * @param string $startWeight
 * @return User
 */
public function setStartWeight($startWeight)
{
    $this->start_weight = $startWeight;

    return $this;
}

/**
 * Get start_weight
 *
 * @return string 
 */
public function getStartWeight()
{
    return $this->start_weight;
}

And here is the entity manager in the indexAction

$email = $form->get('email')->getData();
            $user->setEmail($email);
            $first_name = $form->get('first_name')->getData();
            $user->setFirstname($first_name);
            $last_name = $form->get('last_name')->getData();
            $user->setLastname($last_name);
            $start_weight = $form->get('start_weight');
            $user->setStartWeight($start_weight);

            $em = $this->getDoctrine()->getManager();
            $em->persist($user);
            $em->flush();

when I run the code I get the Catchable Fatal Error Can't Convert to String. Through my searching here and elsewhere on internet land I know I need to add a __toString() method to my User Entity but I'm not sure exactly what to return.

1 Answer 1

3

You forgot to call getData() method on the start_weight child form type.

Sign up to request clarification or add additional context in comments.

1 Comment

DOH! So i did, thanks for looking, that was an easy fix. Will mark you momentarily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.