Skip to content

Commit

Permalink
fixed geometry field not present in XML
Browse files Browse the repository at this point in the history
  • Loading branch information
alagroy-42 committed Oct 1, 2020
1 parent 6ca214f commit a5b3bd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lizmap/modules/lizmap/lib/Form/QgisForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,20 @@ 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
$defaultValue = $this->getDefaultValue($fieldName);

$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);
Expand Down
8 changes: 5 additions & 3 deletions lizmap/modules/lizmap/lib/Form/QgisFormControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand All @@ -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
Expand Down

0 comments on commit a5b3bd1

Please sign in to comment.