code/controllers/EventAttendeeController.php
public function add($request) {
		$tickets = $this->registration->Event()->getAvailableTickets();
		$form = $this->AttendeeForm();
		// check tickets are actually available
		if (!$tickets->count()) {
			return $this->redirect($this->BackURL);
		}
		$formHasData = $form->hasSessionData();

		$attendee = $this->createAttendee();
		// ticket selection in url
		$ticket = $tickets->byID((int)$request->param('ID'));
		if($ticket && !$ticket->exists()){
			$attendee->TicketID = $ticket->ID;
			$form->setAllowedTickets(
				$this->registration->Event()->getAvailableTickets()
			);
		}
		
		// ticket is always required
		if($ticket) {
			$form->loadDataFrom(array(
				"TicketID" => $ticket->ID
			));
		}else{
			$form->setAllowedTickets(
				$this->registration->Event()->getAvailableTickets()
			);
		}
		if(!$formHasData){
			// load any default data
			$form->loadDataFrom($attendee);
			// automatically populate from previous attendee
			$this->populatePreviousData($form);
		}
		$this->extend("onAdd", $form, $this->registration);
		return array(
			'Title' => $ticket ? $ticket->Title : null,
			'Form' => $form
		);
	}
public function add($request) {
		$tickets = $this->registration->Event()->getAvailableTickets();
		$form = $this->AttendeeForm();
		// check tickets are actually available
		if (!$tickets->count()) {
			return $this->redirect($this->BackURL);
		}
		$formHasData = $form->hasSessionData();

		$attendee = $this->createAttendee();
		// ticket selection in url
		$ticket = $tickets->byID((int)$request->param('ID'));
		if($ticket && !$ticket->exists()){
			$attendee->TicketID = $ticket->ID;
			$form->setAllowedTickets(
				$this->registration->Event()->getAvailableTickets()
			);
		}
		
		// ticket is always required
		if($ticket) {
			$form->loadDataFrom(array(
				"TicketID" => $ticket->ID
			));
		}else{
			$form->setAllowedTickets(
				$this->registration->Event()->getAvailableTickets()
			);
		}
		if(!$formHasData){
			// load any default data
			$form->loadDataFrom($attendee);
			// automatically populate from previous attendee
			$this->populatePreviousData($form);
		}
		$this->extend("onAdd", $form, $this->registration);
		return array(
			'Title' => $ticket ? $ticket->Title : null,
			'Form' => $form
		);
	}
public function add ( $ request ) { $ tickets = $ this -> registration -> Event ( ) -> getAvailableTickets ( ) ; $ form = $ this -> AttendeeForm ( ) ; // check tickets are actually available if ( ! $ tickets -> count ( ) ) { return $ this -> redirect ( $ this -> BackURL ) ; } $ formHasData = $ form -> hasSessionData ( ) ; $ attendee = $ this -> createAttendee ( ) ; // ticket selection in url $ ticket = $ tickets -> byID ( ( int ) $ request -> param ( 'ID' ) ) ; if ( $ ticket && ! $ ticket -> exists ( ) ) { $ attendee -> TicketID = $ ticket -> ID ; $ form -> setAllowedTickets ( $ this -> registration -> Event ( ) -> getAvailableTickets ( ) ) ; } // ticket is always required if ( $ ticket ) { $ form -> loadDataFrom ( array ( "TicketID" => $ ticket -> ID ) ) ; } else { $ form -> setAllowedTickets ( $ this -> registration -> Event ( ) -> getAvailableTickets ( ) ) ; } if ( ! $ formHasData ) { // load any default data $ form -> loadDataFrom ( $ attendee ) ; // automatically populate from previous attendee $ this -> populatePreviousData ( $ form ) ; } $ this -> extend ( "onAdd" , $ form , $ this -> registration ) ; return array ( 'Title' => $ ticket ? $ ticket -> Title : null , 'Form' => $ form ) ; }
Add action renders the add attendee form.
@param HTTPRequest $request
@return array
Add action renders the add attendee form .