mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUG: Fixes #166 for SQL server which does not like empty strings as numerics
This commit is contained in:
parent
d3e4b8a5e8
commit
99de36afef
@ -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');
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user