Browse Source

FD3-800 when editing a subnet the address field is readonly

Guillermo Espinoza 6 năm trước cách đây
mục cha
commit
169fec19dc

+ 13 - 2
src/IPv4Bundle/Admin/SubNetAdmin.php

@@ -59,10 +59,21 @@ class SubNetAdmin extends BaseAdmin
      */
     protected function configureFormFields(FormMapper $formMapper)
     {
+        $addressOptions = [
+            'sonata_help' => $this->trans('subnet.address.readonly'),
+        ];
+        // setting address field to readonly when editing a subnet
+        if ($this->getSubject()->getId()) {
+            $addressOptions['attr'] = [
+                'readonly' => true,
+                'disable' => true,
+            ];
+        }
+
         $formMapper
             ->tab('SubNet')
             ->with('')
-                ->add('address')
+                ->add('address', null, $addressOptions)
                 ->add('allowedHostType')
                 ->add('status', ChoiceType::class, [
                     'choices' => HostStatus::getChoices(),
@@ -71,7 +82,7 @@ class SubNetAdmin extends BaseAdmin
                 ->add('netGroup')
             ->end()
             ->end()
-    ;
+        ;
     }
 
     /**

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

@@ -145,3 +145,4 @@ State: Estado
 active: Activo
 suspended: Suspendido
 disabled: Inactivo
+subnet.address.readonly: El campo Dirección no se puede editar una vez creada la Subred