/** Add an event * @access public * @return void * @todo geocoding and processing in view */ public function addAction() { $form = new EventForm(); $form->details->setLegend('Add a new event'); $form->submit->setLabel('Save event'); $this->view->form = $form; if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) { $this->_events->add($form->getValues()); $this->getFlash()->addMessage('New event created!'); $this->redirect('/admin/events/'); } else { $form->populate($this->_request->getPost()); } }
/** * @test */ public function addAddsEventToList() { $event = $this->getMockBuilder(Event::class)->getMock(); $instance = new Events(); $instance->add($event); self::assertCount(1, $instance->getIterator()); }
//Haal landen op $landen = new Land(); $landen = $landen->get_all(); $events = new Events(); //Check of er POST waarde is if ($_SERVER['REQUEST_METHOD'] === 'POST') { //Valideer post attr if ($_POST && isset($_POST['naam'], $_POST['omschrijving'], $_POST['datum'], $_POST['type'], $_POST['genre'], $_POST['plaatsnaam'], $_POST['land'])) { $naam = test_input($_POST['naam']); $omschrijving = test_input($_POST['omschrijving']); $datum = test_input($_POST['datum']); $type = test_input($_POST['type']); $genre = test_input($_POST['genre']); $plaatsnaam = test_input($_POST['plaatsnaam']); $land = test_input($_POST['land']); $event = $events->add($type, $genre, $land, $plaatsnaam, $naam, $omschrijving, $datum, $usr['id']); if ($event) { $event = $events->get($event); if ($event) { ?> <script> $.notify("Evenement is succesvol aangemaakt!", "success"); </script> <?php header('HTTP/1.0 302 Found'); header("Location: index.php?map=events&page=edit&id=" . $event['events_id']); } else { ?> <script> $.notify("Evenement kon niet worden aangemaakt", "error"); </script>