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.

Form Questions /

Losing ID in my form




Community Member, 153 Posts

14 April 2010 at 12:55pm

Edited: 14/04/2010 12:56pm

Hi, need some help here with a form which I'm using in the front end to update a dataobject. Basically I'm getting a blank page when I submit my form, I've done some debugging and testing and it seems to be losing the id.

Any ideas where I'm going wrong anyone?

Here is my code:


class CallerDatabase extends Page{

class CallerDatabase_Controller extends Page_Controller{

   public function displayCallEvent(){
      $params = Director::urlParams();
      return (!isset($params['Action']));

   public function displayEditCallForm(){
      $params = Director::urlParams();
      return (isset($params['Action']) && $params['Action'] == 'editcall');

   public function displayIndividualCallDetails(){
      $params = Director::urlParams();
      return (isset($params['Action']) && $params['Action'] == 'viewcall');

   public function CallEvent(){
      return DataObject::get("CallEvent");

   public function getIndividualCallDetails(){

      if($urlID = Director::URLParam('ID')){

         $CallEventID = Convert::raw2xml($urlID);

            return DataObject::get_by_id('CallEvent', $CallEventID);

   public function EditCallEvent(){

      $urlAction = Director::URLParam('Action');

         $urlID = Convert::raw2sql(Director::urlParam('ID'));

         $CallEvent = DataObject::get_by_id("CallEvent", Convert::raw2sql(Director::urlParam('ID')));
         $PersonDetail = DataObject::get_by_id("PersonDetail", Convert::raw2sql(Director::urlParam('ID')));

      $fields = new FieldSet(
            new HiddenField('ID','ID: ', $urlID),
            new TextField('FirstName', 'First name', $PersonDetail->FirstName),
            new TextField('Surname', 'Surname', $PersonDetail->Surname),
            new TextField('Age', 'Age', $PersonDetail->Age),

         $actions = new FieldSet(
            new FormAction("UpdateCallEvent", "Update")

         return new Form($this, "EditCallEvent", $fields, $actions);
   public function UpdateCallEvent($data, $form){

      $PersonDetail = DataObject::get_by_id('PersonDetail', Convert::raw2sql($data['ID']));

            $PersonDetail->FirstName = $data['FirstName']; // sets property on object
            $PersonDetail->Surname = $data['Surname']; // sets property on object
            $PersonDetail->Age = $data['Age']; // sets property on object
            $PersonDetail->write(); // writes row to database

      Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");

   public function Success(){
      return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";