AntonLV 8 лет назад
Родитель
Сommit
5ec2ca73c4

+ 4 - 2
studio/classes/BxDolStudioFormsField.php

@@ -22,6 +22,7 @@ class BxDolStudioFormsField extends BxDol
 
     protected $aParams = array();
     protected $aField = array();
+    protected $iFieldNameMaxLen;
 
     public function __construct($aParams = array(), $aField = array())
     {
@@ -75,6 +76,7 @@ class BxDolStudioFormsField extends BxDol
 
         $this->aParams = $aParams;
         $this->aField = $aField;
+        $this->iFieldNameMaxLen = 32;
     }
 
     public function init()
@@ -100,12 +102,12 @@ class BxDolStudioFormsField extends BxDol
         return $this->oDb->alterAdd($this->aParams['table'], $sName, $this->aParams['table_field_type']);
     }
 
-	public function alterChange($sNameOld, $sNameNews)
+	public function alterChange($sNameOld, $sNameNew)
     {
         if(!isset($this->aParams['table'], $this->aParams['table_alter'], $this->aParams['table_field_type']) || $this->aParams['table_alter'] !== true)
             return '';
 
-        return $this->oDb->alterChange($this->aParams['table'], $sNameOld, $sNameNews, $this->aParams['table_field_type']);
+        return $this->oDb->alterChange($this->aParams['table'], $sNameOld, $sNameNew, $this->aParams['table_field_type']);
     }
 
     public function alterRemove($sName)

+ 17 - 7
studio/template/scripts/BxBaseStudioFormsField.php

@@ -122,13 +122,18 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField
 	            BxDolForm::setSubmittedValue('name', $sInputName, $oForm->aFormAttrs['method']);
             }
 
+            $sFieldName = strmaxtextlen($sInputName, $this->iFieldNameMaxLen, '');
+            if(strcmp($sInputName, $sFieldName) !== 0)
+            	BxDolForm::setSubmittedValue('name', $sFieldName, $oForm->aFormAttrs['method']);
+
             $this->onSubmitField($oForm);
             if(($iId = $oForm->insert()) === false)
                 return false;
 
-            $this->alterAdd($sInputName);
+            $this->alterAdd($sFieldName);
             return true;
-        } else
+        } 
+        else
             return BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-add-' . $this->aParams['display'] . '-popup', _t('_adm_form_txt_field_add_popup'), BxDolStudioTemplate::getInstance()->parseHtmlByName('form_add_field.html', array(
                 'form_id' => $aForm['form_attrs']['id'],
                 'form' => $oForm->getCode(true),
@@ -148,18 +153,23 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField
 
         $oForm->initChecker();
         if($oForm->isSubmittedAndValid()) {
-        	$sInputNameOld = $this->aField['name'];
-            $sInputNameNew = $oForm->getCleanValue('name');
+            $sInputName = $oForm->getCleanValue('name');
+
+			$sFieldName = strmaxtextlen($sInputName, $this->iFieldNameMaxLen, '');
+            if(strcmp($sInputName, $sFieldName) !== 0)
+            	BxDolForm::setSubmittedValue('name', $sFieldName, $oForm->aFormAttrs['method']);
 
             $this->onSubmitField($oForm);
             if($oForm->update((int)$this->aField['id']) === false)
                 return false;
 
-			if($bAlter || strcmp($sInputNameOld, $sInputNameNew) !== 0)
-				$this->alterChange($sInputNameOld, $sInputNameNew);
+			$sFieldNameOld = $this->aField['name'];
+			if($bAlter || strcmp($sFieldNameOld, $sFieldName) !== 0)
+				$this->alterChange($sFieldNameOld, $sFieldName);
 
             return true;
-        } else
+        } 
+        else
             return BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-edit-' . $this->aField['type'] . '-popup', _t('_adm_form_txt_field_edit_popup', _t($this->aField['caption_system'])), BxDolStudioTemplate::getInstance()->parseHtmlByName('form_add_field.html', array(
                 'form_id' => $aForm['form_attrs']['id'],
                 'form' => $oForm->getCode(true),