I have a weird bug in controller with Symfony4Can an ASP.NET MVC controller return an Image?FOSRest Symfony POST using jsonSymfony2 - Dynamic generated form not working while editing formSymfony4 extends controller with route annotationSymfony4 API Controller ParentSymfony4: inject service into controller __construct (constructor)migrating sql query controller symfony4How to display the 404 error page instead bugs in Symfony4Generating new entities in Symfony4 controllerSymfony4 resource controller

Move up, right, left and down functions

Does friction always oppose motion?

Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?

What's the lunar calendar of two moons

Having to constantly redo everything because I don't know how to do it

Definition of an European Option

How far can gerrymandering go?

Dynamic SQL query - how do I add an int to the code?

Is this house-rule removing the increased effect of cantrips at higher character levels balanced?

Word ending in "-ine" for rat-like

Chandra exiles a card, I play it, it gets exiled again

Does "boire un jus" tend to mean "coffee" or "juice of fruit"?

Can a quantum computer run classical algorithms?

Position representation of spin states and spin operators

Apollo Mission Control Room 2, how do these decimal number displays work?

Fitting large table to single page

Customs and immigration on a USA-UK-Sweden flight itinerary

iMac 2019: Can I mix the old modules with the new ones when upgrading RAM?

"I am [the / an] owner of a bookstore"?

Which high-degree derivatives play an essential role?

Why should I allow multiple IP addresses on a website for a single session?

What is the lowest possible AC?

Why is my 401k manager recommending me to save more?

Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?



I have a weird bug in controller with Symfony4


Can an ASP.NET MVC controller return an Image?FOSRest Symfony POST using jsonSymfony2 - Dynamic generated form not working while editing formSymfony4 extends controller with route annotationSymfony4 API Controller ParentSymfony4: inject service into controller __construct (constructor)migrating sql query controller symfony4How to display the 404 error page instead bugs in Symfony4Generating new entities in Symfony4 controllerSymfony4 resource controller













-1















This is my controller



 $entretien = new Entretien();
$form3 = $this->createForm(EntretienType::class, $entretien); // entretien type has a attribute debutRdv
$form3->add('duree', TimeType::class, [
'placeholder' => [
'hour' => 'Heure', 'minute' => 'Minute', 'second' => 'Seconde',
],
'with_seconds' => true,
"mapped" => false,
]);

$form3->handleRequest($request);

if($form3->isSubmitted())
{
$debutRdv= $entretien->getDebutRdv(); // getdata from form

$duree =$form3->get("duree")->getData();

$duree = $duree->format('PTHHiMsS');
/*------------Here the probleme--------*/
$finRdv = $debutRdv->add(new DateInterval($duree));
/*-------------------------------------*/
...


The problem is when I write $debutRdv->add(...) the attribute $debutRdv changes to $finRdv like I've done $debutRdv = $finRdv;



For example
$debutRdv: "2019-03-25 16:30:00"
$duree : "0:30:00"



When I write this



$finRdv = $debutRdv->add(new DateInterval($duree));


$duree and $debutRdv change to 2019-03-25 17:00:00
but I only want $duree got 2019-03-25 17:00:00



I want to solve this problem because
$entretien->getDebutRdv() also changes to 2019-03-25 17:00:00 Like I have done $entretien->setDebutRdv($duree)










share|improve this question




























    -1















    This is my controller



     $entretien = new Entretien();
    $form3 = $this->createForm(EntretienType::class, $entretien); // entretien type has a attribute debutRdv
    $form3->add('duree', TimeType::class, [
    'placeholder' => [
    'hour' => 'Heure', 'minute' => 'Minute', 'second' => 'Seconde',
    ],
    'with_seconds' => true,
    "mapped" => false,
    ]);

    $form3->handleRequest($request);

    if($form3->isSubmitted())
    {
    $debutRdv= $entretien->getDebutRdv(); // getdata from form

    $duree =$form3->get("duree")->getData();

    $duree = $duree->format('PTHHiMsS');
    /*------------Here the probleme--------*/
    $finRdv = $debutRdv->add(new DateInterval($duree));
    /*-------------------------------------*/
    ...


    The problem is when I write $debutRdv->add(...) the attribute $debutRdv changes to $finRdv like I've done $debutRdv = $finRdv;



    For example
    $debutRdv: "2019-03-25 16:30:00"
    $duree : "0:30:00"



    When I write this



    $finRdv = $debutRdv->add(new DateInterval($duree));


    $duree and $debutRdv change to 2019-03-25 17:00:00
    but I only want $duree got 2019-03-25 17:00:00



    I want to solve this problem because
    $entretien->getDebutRdv() also changes to 2019-03-25 17:00:00 Like I have done $entretien->setDebutRdv($duree)










    share|improve this question


























      -1












      -1








      -1








      This is my controller



       $entretien = new Entretien();
      $form3 = $this->createForm(EntretienType::class, $entretien); // entretien type has a attribute debutRdv
      $form3->add('duree', TimeType::class, [
      'placeholder' => [
      'hour' => 'Heure', 'minute' => 'Minute', 'second' => 'Seconde',
      ],
      'with_seconds' => true,
      "mapped" => false,
      ]);

      $form3->handleRequest($request);

      if($form3->isSubmitted())
      {
      $debutRdv= $entretien->getDebutRdv(); // getdata from form

      $duree =$form3->get("duree")->getData();

      $duree = $duree->format('PTHHiMsS');
      /*------------Here the probleme--------*/
      $finRdv = $debutRdv->add(new DateInterval($duree));
      /*-------------------------------------*/
      ...


      The problem is when I write $debutRdv->add(...) the attribute $debutRdv changes to $finRdv like I've done $debutRdv = $finRdv;



      For example
      $debutRdv: "2019-03-25 16:30:00"
      $duree : "0:30:00"



      When I write this



      $finRdv = $debutRdv->add(new DateInterval($duree));


      $duree and $debutRdv change to 2019-03-25 17:00:00
      but I only want $duree got 2019-03-25 17:00:00



      I want to solve this problem because
      $entretien->getDebutRdv() also changes to 2019-03-25 17:00:00 Like I have done $entretien->setDebutRdv($duree)










      share|improve this question
















      This is my controller



       $entretien = new Entretien();
      $form3 = $this->createForm(EntretienType::class, $entretien); // entretien type has a attribute debutRdv
      $form3->add('duree', TimeType::class, [
      'placeholder' => [
      'hour' => 'Heure', 'minute' => 'Minute', 'second' => 'Seconde',
      ],
      'with_seconds' => true,
      "mapped" => false,
      ]);

      $form3->handleRequest($request);

      if($form3->isSubmitted())
      {
      $debutRdv= $entretien->getDebutRdv(); // getdata from form

      $duree =$form3->get("duree")->getData();

      $duree = $duree->format('PTHHiMsS');
      /*------------Here the probleme--------*/
      $finRdv = $debutRdv->add(new DateInterval($duree));
      /*-------------------------------------*/
      ...


      The problem is when I write $debutRdv->add(...) the attribute $debutRdv changes to $finRdv like I've done $debutRdv = $finRdv;



      For example
      $debutRdv: "2019-03-25 16:30:00"
      $duree : "0:30:00"



      When I write this



      $finRdv = $debutRdv->add(new DateInterval($duree));


      $duree and $debutRdv change to 2019-03-25 17:00:00
      but I only want $duree got 2019-03-25 17:00:00



      I want to solve this problem because
      $entretien->getDebutRdv() also changes to 2019-03-25 17:00:00 Like I have done $entretien->setDebutRdv($duree)







      php symfony controller symfony4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 14:23









      Stephen S

      2,3951 gold badge12 silver badges24 bronze badges




      2,3951 gold badge12 silver badges24 bronze badges










      asked Mar 25 at 16:26









      KhalilKhalil

      979 bronze badges




      979 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          2














          This is the default behaviour of DateTime instances: add method changes object it is called from. If you don't want $debutRdv to be changed, you can clone it to $finRdv and apply add:



          $finRdv = clone $debutRdv;
          // see, here's no `=` as `add()` will directly change `$finRdv`
          $finRdv->add(new DateInterval($duree));





          share|improve this answer























          • Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

            – Khalil
            Mar 25 at 16:40










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342329%2fi-have-a-weird-bug-in-controller-with-symfony4%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          This is the default behaviour of DateTime instances: add method changes object it is called from. If you don't want $debutRdv to be changed, you can clone it to $finRdv and apply add:



          $finRdv = clone $debutRdv;
          // see, here's no `=` as `add()` will directly change `$finRdv`
          $finRdv->add(new DateInterval($duree));





          share|improve this answer























          • Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

            – Khalil
            Mar 25 at 16:40















          2














          This is the default behaviour of DateTime instances: add method changes object it is called from. If you don't want $debutRdv to be changed, you can clone it to $finRdv and apply add:



          $finRdv = clone $debutRdv;
          // see, here's no `=` as `add()` will directly change `$finRdv`
          $finRdv->add(new DateInterval($duree));





          share|improve this answer























          • Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

            – Khalil
            Mar 25 at 16:40













          2












          2








          2







          This is the default behaviour of DateTime instances: add method changes object it is called from. If you don't want $debutRdv to be changed, you can clone it to $finRdv and apply add:



          $finRdv = clone $debutRdv;
          // see, here's no `=` as `add()` will directly change `$finRdv`
          $finRdv->add(new DateInterval($duree));





          share|improve this answer













          This is the default behaviour of DateTime instances: add method changes object it is called from. If you don't want $debutRdv to be changed, you can clone it to $finRdv and apply add:



          $finRdv = clone $debutRdv;
          // see, here's no `=` as `add()` will directly change `$finRdv`
          $finRdv->add(new DateInterval($duree));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 16:30









          u_mulderu_mulder

          40k5 gold badges31 silver badges49 bronze badges




          40k5 gold badges31 silver badges49 bronze badges












          • Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

            – Khalil
            Mar 25 at 16:40

















          • Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

            – Khalil
            Mar 25 at 16:40
















          Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

          – Khalil
          Mar 25 at 16:40





          Its worked thank you, $finRdv = clone $debutRdv; $finRdv=$finRdv->add(new DateInterval($duree));

          – Khalil
          Mar 25 at 16:40






          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55342329%2fi-have-a-weird-bug-in-controller-with-symfony4%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해