diff --git a/cypress/e2e/ui/people/standard.person.profile.spec.js b/cypress/e2e/ui/people/standard.person.profile.spec.js index ddfd56bd18..7fc075333b 100644 --- a/cypress/e2e/ui/people/standard.person.profile.spec.js +++ b/cypress/e2e/ui/people/standard.person.profile.spec.js @@ -34,7 +34,17 @@ context("Person Profile", () => { cy.get("#editWhyCame").click(); cy.url().should("contains", `WhyCameEditor.php?PersonID=${personId}`); + cy.get('tr:nth-child(1) textarea').clear().type('{backspace}'); + cy.get('tr:nth-child(1) textarea').clear().type('I love the lord '); + cy.get('tr:nth-child(2) textarea').clear().type('{backspace}'); + cy.get('tr:nth-child(2) textarea').clear().type('{backspace}'); + cy.get('tr:nth-child(2) textarea').clear().type('the feeling of being included'); + cy.get('tr:nth-child(3) textarea').clear().type('More Youth Meetings'); + cy.get('tr:nth-child(4) textarea').clear().type('The website '); + cy.get('td > .btn-primary').click(); + + cy.url().should('contains', 'WhyCameEditor.php'); + cy.contains('More Youth Meetings'); - // TODO: add editing }); }); diff --git a/src/WhyCameEditor.php b/src/WhyCameEditor.php index baa6436385..c7d5737bf3 100644 --- a/src/WhyCameEditor.php +++ b/src/WhyCameEditor.php @@ -29,27 +29,21 @@ $tSuggest = InputUtils::legacyFilterInput($_POST['Suggest']); $tHearOfUs = InputUtils::legacyFilterInput($_POST['HearOfUs']); - // New input (add) - if (strlen($iWhyCameID) < 1) { + $whyCame = WhyCameQuery::create()->findOneByPerId($iPerson); + if ($whyCame === null) { + LoggerUtils::getAppLogger()->info("person id " . $iPerson . " whycame id null" ); $whyCame = new WhyCame(); - $whyCame - ->setPerId($iPerson) - ->setJoin($tJoin) - ->setCome($tCome) - ->setSuggest($tSuggest) - ->setHearOfUs($tHearOfUs); - $whyCame->save(); - // Existing record (update) - } else { - $whyCame = WhyCameQuery::create()->findOneByPerId($iPerson); - $whyCame - ->setJoin($tJoin) - ->setCome($tCome) - ->setSuggest($tSuggest) - ->setHearOfUs($tHearOfUs); - $whyCame->save(); + $whyCame->setPerId($iPerson); } + $whyCame + ->setJoin($tJoin) + ->setCome($tCome) + ->setSuggest($tSuggest) + ->setHearOfUs($tHearOfUs); + + $whyCame->save(); + if (isset($_POST['Submit'])) { // Check for redirection to another page after saving information: (ie. PledgeEditor.php?previousPage=prev.php?a=1;b=2;c=3) if ($linkBack != '') {