Prechádzať zdrojové kódy

Se soluciona el problema del campo null en la DB pero con valor en las
vistas. FD3-624

Maximiliano Schvindt 6 rokov pred
rodič
commit
d629395943

+ 2 - 2
src/CablemodemBundle/Admin/ProfileAdmin.php

@@ -54,8 +54,8 @@ class ProfileAdmin extends BaseAdmin
     {
         $formMapper
             ->add('name')
-            ->add('downstream',null,array('help' => $this->trans('help.profile_downstream')))
-            ->add('upstream',null,array('help' => $this->trans('help.profile_downstream')))
+            ->add('downstream',null,array('help' => $this->trans('help.profile_downstream'), 'attr' => array('placeholder' => $this->trans('help.profile_value_default'))))
+            ->add('upstream',null,array('help' => $this->trans('help.profile_downstream'), 'attr' => array('placeholder' => $this->trans('help.profile_value_default'))))
             ->add('filtroUpload')
             ->add('filtroDownload')
             ->add('maxCpe')

+ 17 - 2
src/CablemodemBundle/Entity/Profile.php

@@ -82,6 +82,11 @@ class Profile  implements TenancyIdTraitInterface
      */
     protected $maxCpe;
 
+    public function __construct()
+    {
+        $this->downstream = $this->getDefault('downstream');
+        $this->upstream = $this->getDefault('upstream');
+    }
 
     /**
      * @return string
@@ -166,7 +171,12 @@ class Profile  implements TenancyIdTraitInterface
      */
     public function setDownstream($downstream)
     {
-        $this->downstream = $downstream;
+        if(is_null($downstream)) {
+            $this->downstream = $this->getDefault('downstream');
+        } else {
+            $this->downstream = $downstream;
+        }
+        
 
         return $this;
     }
@@ -178,7 +188,12 @@ class Profile  implements TenancyIdTraitInterface
      */
     public function setUpstream($upstream)
     {
-        $this->upstream = $upstream;
+        if(is_null($upstream)) {
+            $this->upstream = $this->getDefault('upstream');
+        } else {
+            $this->upstream = $upstream;
+        }
+
 
         return $this;
     }

+ 1 - 0
src/CablemodemBundle/Resources/translations/CablemodemBundle.es.yml

@@ -158,3 +158,4 @@ voip.password: Password
 voip.technology: Tecnología
 help:
     profile_downstream: Expresado en bits
+    profile_value_default: Al deja en blanco el valor, se asignará un valor por defecto!