Skip to main content
deleted 3855 characters in body; edited tags
Source Link
Peyman Mohamadpour
  • 18k
  • 24
  • 94
  • 102

I have a problem, I want to put a numberType tonumber into a NumberType field, but when I try I haveget this messageexception:

There is my intervention Entity:Intervention

id;}/*** Set comments** @param string $comments** @return Intervention*/public function setComments($comments){$this->comments = $comments;return $this;}/*** Get comments** @return string*/public function getComments(){return $this->comments;}/*** Get materialCost** @return MaterialCost*/public function getMaterialCost(){return $this->materialCost;}/*** Set materialCost** @param \GestionBundle\Entity\MaterialCost $materialCost** @return Intervention*/public function setMaterialCost($materialCost){$this->materialCost = $materialCost;}public function __toString(){if(is_null($this->comments)){return '';}return $this->comments;}}There is my MaterialCost Entity:id;}/*** Set materialCost** @param float $materialCost** @return MaterialCost*/public function setMaterialCost($materialCost){$this->materialCost = $materialCost;return $this;}/*** Get materialCost** @return float*/public function getMaterialCost(){return $this->materialCost;}/*** Set intervention** @param \GestionBundle\Entity\Intervention $intervention** @return MaterialCost*/public function setIntervention($intervention){$this->intervention = $intervention;return $this;}/*** Get intervention** @return Intervention*/public function getIntervention(){return $this->intervention;}public function __toString(){return(string) $this->materialCost;}}My InterventionType:add('materialCost', NumberType::class, ['required' => true])->add('comments', TextareaType::class, ['required' => false]);}/***{@inheritdoc}*/public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(array('data_class' => 'GestionBundle\Entity\MaterialCost'));}/***{@inheritdoc}*/public function getBlockPrefix(){return 'gestionbundle_materialcost';}}Thanks for advance
namespace GestionBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\OneToOne; /** * @ORM\Entity */ class Intervention { /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="comments", type="text", nullable=true) */ private $comments; /** * One Intervention has One materialCost. * @OneToOne(targetEntity="MaterialCost", inversedBy="intervention", cascade={"persist"}) */ private $materialCost; public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } 

MaterialCost

namespace GestionBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class MaterialCost { /* * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var float * @ORM\Column(name="material_cost", type="float") */ private $materialCost; /** * @ORM\OneToOne(targetEntity="Intervention", mappedBy="materialCost") */ private $intervention; public function __toString() { return (string) $this->materialCost; } } 

InterventionType

namespace GestionBundle\Form; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class InterventionType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } } 

I have a problem, I want to put a numberType to a field but when I try I have this message:

There is my intervention Entity:

id;}/*** Set comments** @param string $comments** @return Intervention*/public function setComments($comments){$this->comments = $comments;return $this;}/*** Get comments** @return string*/public function getComments(){return $this->comments;}/*** Get materialCost** @return MaterialCost*/public function getMaterialCost(){return $this->materialCost;}/*** Set materialCost** @param \GestionBundle\Entity\MaterialCost $materialCost** @return Intervention*/public function setMaterialCost($materialCost){$this->materialCost = $materialCost;}public function __toString(){if(is_null($this->comments)){return '';}return $this->comments;}}There is my MaterialCost Entity:id;}/*** Set materialCost** @param float $materialCost** @return MaterialCost*/public function setMaterialCost($materialCost){$this->materialCost = $materialCost;return $this;}/*** Get materialCost** @return float*/public function getMaterialCost(){return $this->materialCost;}/*** Set intervention** @param \GestionBundle\Entity\Intervention $intervention** @return MaterialCost*/public function setIntervention($intervention){$this->intervention = $intervention;return $this;}/*** Get intervention** @return Intervention*/public function getIntervention(){return $this->intervention;}public function __toString(){return(string) $this->materialCost;}}My InterventionType:add('materialCost', NumberType::class, ['required' => true])->add('comments', TextareaType::class, ['required' => false]);}/***{@inheritdoc}*/public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(array('data_class' => 'GestionBundle\Entity\MaterialCost'));}/***{@inheritdoc}*/public function getBlockPrefix(){return 'gestionbundle_materialcost';}}Thanks for advance

I want to put a number into a NumberType field, but when I get this exception:

Intervention

namespace GestionBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\OneToOne; /** * @ORM\Entity */ class Intervention { /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="comments", type="text", nullable=true) */ private $comments; /** * One Intervention has One materialCost. * @OneToOne(targetEntity="MaterialCost", inversedBy="intervention", cascade={"persist"}) */ private $materialCost; public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } 

MaterialCost

namespace GestionBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity */ class MaterialCost { /* * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var float * @ORM\Column(name="material_cost", type="float") */ private $materialCost; /** * @ORM\OneToOne(targetEntity="Intervention", mappedBy="materialCost") */ private $intervention; public function __toString() { return (string) $this->materialCost; } } 

InterventionType

namespace GestionBundle\Form; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class InterventionType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } } 
added 18 characters in body
Source Link
delph49
  • 99
  • 1
  • 11

I have a problem, I want to put a numberType to a field but when I try I have this message:

Expected value of type "GestionBundle\Entity\MaterialCost" for association field "GestionBundle\Entity\Intervention#$materialCost", got "double" instead.

There is my intervention Entity:

id; } /** * Set comments * * @param string $comments * * @return Intervention */ public function setComments($comments) { $this->comments = $comments; return $this; } /** * Get comments * * @return string */ public function getComments() { return $this->comments; } /** * Get materialCost * * @return MaterialCost */ public function getMaterialCost() { return $this->materialCost; } /** * Set materialCost * * @param \GestionBundle\Entity\MaterialCost $materialCost * * @return Intervention */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; } public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } There is my MaterialCost Entity: id; } /** * Set materialCost * * @param float $materialCost * * @return MaterialCost */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; return $this; } /** * Get materialCost * * @return float */ public function getMaterialCost() { return $this->materialCost; } /** * Set intervention * * @param \GestionBundle\Entity\Intervention $intervention * * @return MaterialCost */ public function setIntervention($intervention) { $this->intervention = $intervention; return $this; } /** * Get intervention * * @return Intervention */ public function getIntervention() { return $this->intervention; } public function __toString() { return (string) $this->materialCost; } } My InterventionType: add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'gestionbundle_materialcost'; } } Thanks for advance

I have a problem, I want to put a numberType to a field but when I try I have this message:

Expected value of type "GestionBundle\Entity\MaterialCost" for association field "GestionBundle\Entity\Intervention#$materialCost", got "double" instead.

There is my intervention Entity:

id; } /** * Set comments * * @param string $comments * * @return Intervention */ public function setComments($comments) { $this->comments = $comments; return $this; } /** * Get comments * * @return string */ public function getComments() { return $this->comments; } /** * Get materialCost * * @return MaterialCost */ public function getMaterialCost() { return $this->materialCost; } /** * Set materialCost * * @param \GestionBundle\Entity\MaterialCost $materialCost * * @return Intervention */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; } public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } There is my MaterialCost Entity: id; } /** * Set materialCost * * @param float $materialCost * * @return MaterialCost */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; return $this; } /** * Get materialCost * * @return float */ public function getMaterialCost() { return $this->materialCost; } /** * Set intervention * * @param \GestionBundle\Entity\Intervention $intervention * * @return MaterialCost */ public function setIntervention($intervention) { $this->intervention = $intervention; return $this; } /** * Get intervention * * @return Intervention */ public function getIntervention() { return $this->intervention; } public function __toString() { return (string) $this->materialCost; } } My InterventionType: add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'gestionbundle_materialcost'; } }

I have a problem, I want to put a numberType to a field but when I try I have this message:

Expected value of type "GestionBundle\Entity\MaterialCost" for association field "GestionBundle\Entity\Intervention#$materialCost", got "double" instead.

There is my intervention Entity:

id; } /** * Set comments * * @param string $comments * * @return Intervention */ public function setComments($comments) { $this->comments = $comments; return $this; } /** * Get comments * * @return string */ public function getComments() { return $this->comments; } /** * Get materialCost * * @return MaterialCost */ public function getMaterialCost() { return $this->materialCost; } /** * Set materialCost * * @param \GestionBundle\Entity\MaterialCost $materialCost * * @return Intervention */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; } public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } There is my MaterialCost Entity: id; } /** * Set materialCost * * @param float $materialCost * * @return MaterialCost */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; return $this; } /** * Get materialCost * * @return float */ public function getMaterialCost() { return $this->materialCost; } /** * Set intervention * * @param \GestionBundle\Entity\Intervention $intervention * * @return MaterialCost */ public function setIntervention($intervention) { $this->intervention = $intervention; return $this; } /** * Get intervention * * @return Intervention */ public function getIntervention() { return $this->intervention; } public function __toString() { return (string) $this->materialCost; } } My InterventionType: add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'gestionbundle_materialcost'; } } Thanks for advance
Source Link
delph49
  • 99
  • 1
  • 11

Expected value of type for association field , got "double" instead

I have a problem, I want to put a numberType to a field but when I try I have this message:

Expected value of type "GestionBundle\Entity\MaterialCost" for association field "GestionBundle\Entity\Intervention#$materialCost", got "double" instead.

There is my intervention Entity:

id; } /** * Set comments * * @param string $comments * * @return Intervention */ public function setComments($comments) { $this->comments = $comments; return $this; } /** * Get comments * * @return string */ public function getComments() { return $this->comments; } /** * Get materialCost * * @return MaterialCost */ public function getMaterialCost() { return $this->materialCost; } /** * Set materialCost * * @param \GestionBundle\Entity\MaterialCost $materialCost * * @return Intervention */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; } public function __toString() { if (is_null($this->comments)) { return ''; } return $this->comments; } } There is my MaterialCost Entity: id; } /** * Set materialCost * * @param float $materialCost * * @return MaterialCost */ public function setMaterialCost($materialCost) { $this->materialCost = $materialCost; return $this; } /** * Get materialCost * * @return float */ public function getMaterialCost() { return $this->materialCost; } /** * Set intervention * * @param \GestionBundle\Entity\Intervention $intervention * * @return MaterialCost */ public function setIntervention($intervention) { $this->intervention = $intervention; return $this; } /** * Get intervention * * @return Intervention */ public function getIntervention() { return $this->intervention; } public function __toString() { return (string) $this->materialCost; } } My InterventionType: add('materialCost', NumberType::class, ['required' => true]) ->add('comments', TextareaType::class, ['required' => false]) ; } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'GestionBundle\Entity\MaterialCost' )); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'gestionbundle_materialcost'; } }