Skip to content

Commit 61555f5

Browse files
committed
attribute form: lookup attribute fields by name. joined layers might be unavailable at load time (fixes #12146)
1 parent 789435d commit 61555f5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/core/qgsvectorlayer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ QgsAttributeEditorElement* QgsVectorLayer::attributeEditorElementFromDomElement(
17581758
for ( int i = 0; i < childNodeList.size(); i++ )
17591759
{
17601760
QDomElement childElem = childNodeList.at( i ).toElement();
1761-
QgsAttributeEditorElement* myElem = attributeEditorElementFromDomElement( childElem, container );
1761+
QgsAttributeEditorElement *myElem = attributeEditorElementFromDomElement( childElem, container );
17621762
if ( myElem )
17631763
container->addChildElement( myElem );
17641764
}
@@ -1768,7 +1768,7 @@ QgsAttributeEditorElement* QgsVectorLayer::attributeEditorElementFromDomElement(
17681768
else if ( elem.tagName() == "attributeEditorField" )
17691769
{
17701770
QString name = elem.attribute( "name" );
1771-
int idx = *( dataProvider()->fieldNameMap() ).find( name );
1771+
int idx = fieldNameIndex( name );
17721772
newElement = new QgsAttributeEditorField( name, idx, parent );
17731773
}
17741774
else if ( elem.tagName() == "attributeEditorRelation" )

src/gui/qgsattributeform.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ QWidget* QgsAttributeForm::createWidgetFromDef( const QgsAttributeEditorElement
571571
if ( !fieldDef )
572572
break;
573573

574-
int fldIdx = fieldDef->idx();
574+
int fldIdx = vl->fieldNameIndex( fieldDef->name() );
575575
if ( fldIdx < vl->pendingFields().count() && fldIdx >= 0 )
576576
{
577577
const QString widgetType = mLayer->editorWidgetV2( fldIdx );

0 commit comments

Comments
 (0)