Feature request #12615
Mandatory fields in forms
|Assigned to:||-||% Done:||
|Target version:||Future Release - Lower Priority|
|Platform version:||Pull Request or Patch supplied:||No|
when you edit attributes on forms you often want to have some mandatory data. In QGIS forms, there is no way to declare that a field is mandatory and I think that it would be very clever to be able to distinguish such fields, whatever the layer is (independent from the file format/SDBMS).
For the moment, QGIS can connect to SDBMS (PostGIS/Oracle) tables that have mandatory fields. When you edit the attributes of such layers, you only have the information that a field is mandatory when you try to commit the data (the error is sent from the database server) and then you have to fill the form again with the correct values.
I think it would be good for the final user to have mandatory fields and to disable data validation (Ok button) as long as all of those fields are not filled. It would be also great to mark mandatory fields in a different way than other fields in the auto-generated and drag'n drop forms. For example, the QLabel of the mandatory field could be bold or on another color.
For attribute table, the columns titles could also be bold for mandatory fields. Attribute filling is a little bit more complicated to deal than forms as you can freely edit fields on the attribute table, mandatory or not. QGIS could open a message box when you try to save empty mandatory fields. Or perhaps is it better to disable the save button as long as every mandatory field has not been filled. This save button seems to be independent from the save button of the main canvas toolbar.
We should be able to declare a mandatory field whatever layer is (independent from file format or DBMS). For example, you would like to mark a field mandatory even if there is no NOT NULL constraint on the database (because you do not want/can modify constraints on database or because you just want to be sure to have data for this field for a specific project). For DBMS, what could be also very great is a way to automatically mark mandatory the fields on which there is a NOT NULL constraint.
For the configuration dialog box, I think we can add another column named "Mandatory" and for which every line would be unchecked by default. This way, we can quickly declare which field is mandatory and which field is not, even if there is already lots of columns in the "Fields" tab dialog.
Of course, we need a way to store the value for each field in the .qgs project file and change the QGIS API... Much work to do !
But I think that with such a feature, we could add another level of data quality management in QGIS.
|related to QGIS Application - Feature request #12492: defaults for the edit widgets||Closed||04/01/2015|
Also available in: Atom