Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Form not submitted


Go to End


2 Posts   1980 Views

Avatar
djpmedia

Community Member, 13 Posts

4 August 2015 at 9:55pm

I've got a very basis form with multiple fields. This form is used to edit some information stored in a Dataobject. The form renders very well and all the information from the Dataobject is loaded.

When I want to submit nothing will happen and the form is redirected back to it self. It never called the submit function.

Does anyone know what goes wrong while submitting?

public function ReisFormEdit() {
			$bookinghash = Convert::raw2sql(Session::get("bookinghash.ID"));
			$bookingData = ObjectBooking::get()->filter(array('bookinghash' => $bookinghash))->first();
	$GeboorteField = DateField::create("GeboorteDatum")->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setAttribute('required', true);
	
    $fields = new FieldList( 
				OptionsetField::create('personen', 'aantal personen', array('1p' => '1 deelnemer','2p' => '2 deelnemers',)),
            	TextField::create("VoorNaam")->setTitle('Voornaam')->setAttribute('required', true)->setAttribute('placeholder', 'Je voornaam (zoals vermeldt in paspoort)')->addExtraClass('form-control')->setAttribute('required', true)->setAttribute('data-parsley-minlength', '2'),
            	TextField::create("TussenVoegsel")->setTitle('tussenvoegsel')->setAttribute('placeholder', 'Tussenvoegsel')->addExtraClass('form-control'),
            	TextField::create("AchterNaam")->setTitle('Achternaam')->setAttribute('required', true)->setAttribute('placeholder', 'Je achternaam (zoals vermeldt in paspoort)')->addExtraClass('form-control'),
            	TextField::create("RoepNaam")->setTitle('Roepnaam')->setAttribute('placeholder', 'Je roepnaam')->addExtraClass('form-control')->setAttribute('required', true)->setAttribute('data-parsley-mincheck', '2'),
            	TextField::create("StraatNaam")->setTitle('Straatnaam')->setAttribute('required', true)->setAttribute('placeholder', 'Straatnaam')->addExtraClass('form-control'),
            	TextField::create("HuisNummer")->setTitle('Huisnummer')->setAttribute('required', true)->setAttribute('placeholder', 'Huisnummer')->addExtraClass('form-control'),
            	TextField::create("Postcode")->setTitle('postcode')->setAttribute('required', true)->setAttribute('placeholder', 'Postcode')->addExtraClass('form-control'),
            	TextField::create("Woonplaats")->setTitle('Woonplaats')->setAttribute('required', true)->setAttribute('placeholder', 'Woonplaats')->addExtraClass('form-control'),
				$GeboorteField->setTitle('Geboortedatum')->setAttribute('placeholder', $GeboorteField->getConfig('dateformat'))->addExtraClass('form-control'),
            	TextField::create("Nationaliteit")->setTitle('Nationaliteit')->setAttribute('required', true)->setAttribute('placeholder', 'Nationaliteit')->addExtraClass('form-control'),
            	TextField::create("Telefoon")->setTitle('Telefoon')->setAttribute('required', true)->setAttribute('placeholder', 'Telefoonnummer prive')->addExtraClass('form-control'),
            	TextField::create("Mobiel")->setTitle('Mobielnummer')->setAttribute('placeholder', 'Telefoonnummer mobiel')->addExtraClass('form-control')->setCustomValidationMessage('Whoops, looks like you have missed me!'),
            	EmailField::create("Email")->setTitle('Email')->setAttribute('required', true)->setAttribute('placeholder', 'Je e-mailadres')->addExtraClass('form-control'),
            	TextField::create("Paspoortnummer")->setTitle('Paspoortnummer')->setAttribute('required', true)->setAttribute('placeholder', 'Paspoortnummer')->addExtraClass('form-control'),
				DateField::create("PaspoortGeldig")->setAttribute('required', true)->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->addExtraClass('form-control')->setAttribute('placeholder', $GeboorteField->getConfig('dateformat')),
				
				TextField::create("VoorNaam2")->setTitle('Voornaam')->setAttribute('placeholder', 'Je voornaam (zoals vermeldt in paspoort)')->addExtraClass('form-control'),
            	TextField::create("TussenVoegsel2")->setTitle('tussenvoegsel')->setAttribute('placeholder', 'Tussenvoegsel')->addExtraClass('form-control'),
            	TextField::create("AchterNaam2")->setTitle('Achternaam')->setAttribute('placeholder', 'Je achternaam (zoals vermeldt in paspoort)')->addExtraClass('form-control'),
            	TextField::create("RoepNaam2")->setTitle('Roepnaam')->setAttribute('placeholder', 'Je roepnaam')->addExtraClass('form-control'),
            	TextField::create("StraatNaam2")->setTitle('Straatnaam')->setAttribute('placeholder', 'Straatnaam')->addExtraClass('form-control'),
            	TextField::create("HuisNummer2")->setTitle('Huisnummer')->setAttribute('placeholder', 'Huisnummer')->addExtraClass('form-control'),
            	TextField::create("Postcode2")->setTitle('Postcode')->setAttribute('placeholder', 'Postcode')->addExtraClass('form-control'),
            	TextField::create("Woonplaats2")->setTitle('Woonplaats')->setAttribute('placeholder', 'Woonplaats')->addExtraClass('form-control'),
				DateField::create("GeboorteDatum2")->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setTitle('Naam2')->setAttribute('placeholder', $GeboorteField->getConfig('dateformat'))->addExtraClass('form-control'),
            	TextField::create("Nationaliteit2")->setTitle('Nationaliteit')->setAttribute('placeholder', 'Nationaliteit')->addExtraClass('form-control'),
            	TextField::create("Telefoon2")->setTitle('Telefoon')->setAttribute('placeholder', 'Telefoonnummer prive')->addExtraClass('form-control'),
            	TextField::create("Mobiel2")->setTitle('Mobielnummer')->setAttribute('placeholder', 'Telefoonnummer mobiel')->addExtraClass('form-control'),
            	EmailField::create("Email2")->setTitle('Email')->setAttribute('placeholder', 'Je e-mailadres')->addExtraClass('form-control'),
            	TextField::create("Paspoortnummer2")->setTitle('Paspoortnummer')->setAttribute('placeholder', 'Paspoortnummer')->addExtraClass('form-control'),
				DateField::create("PaspoortGeldig2")->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setAttribute('placeholder', $GeboorteField->getConfig('dateformat')),
				
				OptionsetField::create('verblijf', 'aantal personen', array('Eenpersoonskamer' => 'eenpersoonskamer','Tweepersoonskamer op indeling' => 'tweepersoonskamer, op indeling','Tweepersoonkamer eigen keuze' => 'tweepersoonskamer, eigen keuze',)),		
            	TextField::create("VerblijfNaam")->setTitle('Naam')->setAttribute('placeholder', 'Naam kamergenoot')->addExtraClass('form-control'),

				TextField::create("ThuisVoorNaam")->setTitle('Voornaam')->setAttribute('placeholder', 'Voornaam')->addExtraClass('form-control'),
            	TextField::create("ThuisTussenVoegsel")->setTitle('tussenvoegsel')->setAttribute('placeholder', 'Tussenvoegsel')->addExtraClass('form-control'),
            	TextField::create("ThuisAchterNaam")->setTitle('Achternaam')->setAttribute('placeholder', 'Achternaam')->addExtraClass('form-control'),
            	TextField::create("ThuisTelefoon")->setTitle('Telefoon')->setAttribute('placeholder', 'Telefoonnummer prive')->addExtraClass('form-control'),
            	TextField::create("ThuisMobiel")->setTitle('Mobielnummer')->setAttribute('placeholder', 'Telefoonnummer mobiel')->addExtraClass('form-control'),
            	EmailField::create("ThuisEmail")->setTitle('Email')->setAttribute('placeholder', 'E-mailadres')->addExtraClass('form-control'),

				TextareaField::create("Opmerkingen")->setTitle('Opmerkingen')->addExtraClass('form-control'),
				TextareaField::create("Dieet")->setTitle('Dieet')->addExtraClass('form-control'),
				TextareaField::create("Extra")->setTitle('Extra')->addExtraClass('form-control'),
				HiddenField::create("ObjectReizenID")->setValue($this->getCurrentProduct()->ID),
				HiddenField::create("ObjectBookingID")->setValue($bookinghash)
        );
		
			$submit = new FormAction('SubmitEdit');
			$submit->addExtraClass('btn btn-primary pull-right');
		   	$submit->useButtonTag = true;
			$submit->setButtonContent('Wijzigingen opslaan <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>');
        	$actions = new FieldList($submit); 
	       		
			$required = new RequiredFields(array('VoorNaam', 'AchterNaam', 'StraatNaam', 'Nationaliteit', 'Email', 'Woonplaats', 'Telefoon'));
		   	
			$form = new Form($this, 'ReisFormEdit', $fields, $actions, $required);
			//$form->setFormAction(Controller::join_links(BASE_URL, 'boeking', 'ReisFormEdit'));
			$form->setTemplate('FormBoekingReisEdit');
			$form->disableSecurityToken();
			$form->loadDataFrom(ObjectBooking::get()->byID($bookingData->ID));
		return $form;
}

public function SubmitEdit($data, $form) { 
		//return "SUBMIT CHECK";
			 $submission = ObjectBooking::get()->filter(array('bookinghash' => $data['ObjectBookingID']))->first();
            $form->saveInto($submission);
		 	 $submission->bookinghash = $hash;
            $submission->write();     
		     return $this->redirect(Director::baseURL() . 'boeking/check/' . $hash);
    }
		

Avatar
Pyromanik

Community Member, 419 Posts

12 August 2015 at 12:40am

Edited: 12/08/2015 12:42am

Validation will probably be failing (either one of the required fields isn't populating, isn't set, or is setting the value to the wrong format for eg. DateField).
This comes from $Message iirc - since it looks like you're using a CSS 'framework' it's possible you may have supplied your own form template - check to ensure that you've got it set to output messages on both the form itself and on each field within.

If all else fails, try $Form.Debug in your template and see if you can read the error there (and then try to figure out why it's not showing after you've confirmed that's what the issue is).