diff --git a/code/UserFormsGridFieldFilterHeader.php b/code/UserFormsGridFieldFilterHeader.php index ce02ebb..7acfe97 100644 --- a/code/UserFormsGridFieldFilterHeader.php +++ b/code/UserFormsGridFieldFilterHeader.php @@ -36,8 +36,10 @@ class UserFormsGridFieldFilterHeader extends GridFieldFilterHeader { // submitted in this form. $params = $gridField->getForm()->getController()->getURLParams(); + // this is for you SQL server I know you don't see '' as a number + $parentID = (!empty($params['ID'])) ? Convert::raw2sql($params['ID']) : 0; $formFields = SubmittedFormField::get() - ->where(sprintf("SubmittedForm.ParentID = '%s'", Convert::raw2sql($params['ID']))) + ->where(sprintf("SubmittedForm.ParentID = '%s'", $parentID)) ->leftJoin('SubmittedForm', 'SubmittedFormField.ParentID = SubmittedForm.ID') ->sort('Title', 'ASC') ->map('Name', 'Title'); diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 47cdbf7..5cc42c1 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -128,9 +128,11 @@ class UserDefinedForm extends Page { $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); + // make sure a numeric not a empty string is checked against this int column for SQL server + $parentID = (!empty($this->ID)) ? $this->ID : 0; // attach every column to the print view from $columns = SubmittedFormField::get() - ->where("\"SubmittedForm\".\"ParentID\" = '$this->ID'") + ->where("\"SubmittedForm\".\"ParentID\" = '$parentID'") ->leftJoin('SubmittedForm', '"SubmittedFormField"."ParentID" = "SubmittedForm"."ID"') ->map('Name', 'Title'); @@ -163,8 +165,9 @@ class UserDefinedForm extends Page { * @return void */ public function doPublish() { + $parentID = (!empty($this->ID)) ? $this->ID : 0; // remove fields on the live table which could have been orphaned. - $live = Versioned::get_by_stage("EditableFormField", "Live", "\"EditableFormField\".\"ParentID\" = $this->ID"); + $live = Versioned::get_by_stage("EditableFormField", "Live", "\"EditableFormField\".\"ParentID\" = $parentID"); if($live) { foreach($live as $field) {