The code snippets below provide some basic examples of accessing the feature attribute dialog using the pyqgis api. These work in the Python console (tested in QGIS 3.2.2) but I’m sure you could adapt them to make them work in a plugin.
This first snippet just directly opens the feature attribute form for a specified feature. This works by casting QgsFeatureIterator items to a list then using list indexing to access a feature and calling the openFeatureForm() method, passing a layer and feature object as arguments.
layer = iface.activeLayer()
features = layer.getFeatures()
feature_list = list(f for f in features)
feat = feature_list[0]
iface.openFeatureForm(layer, feat, True)
The second code snippet below makes use of the Identify Features map tool and it’s featureIdentified signal when the user clicks on a feature in the active layer to open the attribute form for that feature. It also changes the cursor style to emulate the native identify features tool.
from qgis.gui import QgsMapToolIdentifyFeature
from PyQt5.QtGui import QCursor
def onFeatureIdentified(feat):
iface.openFeatureForm(layer, feat, True)
mapTool = None
canvas = iface.mapCanvas()
layer = iface.activeLayer()
mapTool = QgsMapToolIdentifyFeature(canvas)
mapTool.setLayer(layer)
cursor = QCursor()
cursor.setShape(Qt.WhatsThisCursor)
mapTool.setCursor(cursor)
canvas.setMapTool(mapTool)
mapTool.featureIdentified.connect(onFeatureIdentified)
Credit to @Fransisco Raga in this related question.