diff --git a/lizmap/modules/lizmap/lib/Form/QgisForm.php b/lizmap/modules/lizmap/lib/Form/QgisForm.php index caab55e8fc..754ee0678c 100644 --- a/lizmap/modules/lizmap/lib/Form/QgisForm.php +++ b/lizmap/modules/lizmap/lib/Form/QgisForm.php @@ -103,9 +103,7 @@ public function __construct($layer, $form, $featureId, $loginFilteredOverride, A $toDeactivate = array(); $toSetReadOnly = array(); $json = file_get_contents(realpath(__DIR__.'/../..').'/forms/'.$layer->getProject()->getKey().'.'.$layer->getId().'.form.json'); - $this->appContext->debugObject('json', $json); $formInfos = json_decode($json); - $this->appContext->debugObject('form', $formInfos); foreach ($dataFields as $fieldName => $prop) { // faire qqch pour la geometry @@ -113,7 +111,12 @@ public function __construct($layer, $form, $featureId, $loginFilteredOverride, A $constraints = $this->getConstraints($fieldName); - $formControl = new QgisFormControl($fieldName, $formInfos->{$fieldName}, $prop, $defaultValue, $constraints, $this->appContext); + if (property_exists($formInfos, $fieldName)) { + $formControl = new QgisFormControl($fieldName, $formInfos->{$fieldName}, $prop, $defaultValue, $constraints, $this->appContext); + } else { + // The geometry field is not present in the .XML + $formControl = new QgisFormControl($fieldName, null, $prop, null, $constraints, $this->appContext); + } if ($formControl->isUniqueValue()) { $this->fillControlFromUniqueValues($fieldName, $formControl); diff --git a/lizmap/modules/lizmap/lib/Form/QgisFormControl.php b/lizmap/modules/lizmap/lib/Form/QgisFormControl.php index 57ea095b6a..8655e15f9d 100644 --- a/lizmap/modules/lizmap/lib/Form/QgisFormControl.php +++ b/lizmap/modules/lizmap/lib/Form/QgisFormControl.php @@ -200,9 +200,10 @@ public function __construct($ref, $properties, $prop, $defaultValue = null, $con $this->defaultValue = $defaultValue; $propTab = array('edittype', 'fieldEditType', 'fieldAlias', 'widgetv2configAttr'); - $this->appContext->debugObject('props', $properties); foreach ($propTab as $elem) { - $this->{$elem} = $properties->{$elem}; + if ($properties && property_exists($properties, $elem)) { + $this->{$elem} = $properties->{$elem}; + } } if (!self::$qgisEdittypeMap['builded']) { @@ -223,9 +224,10 @@ public function __construct($ref, $properties, $prop, $defaultValue = null, $con $this->required = false; } - $markup = $properties->markup; if ($this->fieldDataType == 'geometry') { $markup = 'hidden'; + } else { + $markup = $properties->markup; } // Create the control