EPSCoR / ERCore

ERcore content management system to assist with NSF EPSCoR reporting
4 stars 7 forks source link

Required status check does not work for fields not named field_ #69

Open kgolde opened 7 years ago

kgolde commented 7 years ago

Required status check does not work for fields with names beginning with "field_". This is shown by the Abstract field in the Publication content type.

The Abstract field in the Publication content type does not respond to the Required condition when the user sets publication Status to "Published". When the user does not enter data into the Abstract field and hits the Save button, drupal does not report that data for the required Abstract field is missing.

Abstract is the label for the drupal field with machine name "body" Most ERCore fields have the machine name beginning with "field_" or "fielder"

The code to process the states in a form is in form_logic.inc The function states_validate inspects each field for required state, but only for fields with names that start with "field_". Thus, the Abstract field which has the machine name "body" does not get checked for the required state. Modifying the code to consider the "body" field presents another issue.

We in Rhode Island have our fields tagged with a language. By default, most of the fields have the language set to "und". However the "body" field has its language set to "en". The function check_rule parses out the field name and language from the condition rule array and uses the language for the form field as well. However, the language for the condition field may differ from the form field. This is true for the "body" field. The language for the condition field is passed as arguments to the check_field_required and get_field_title functions. Instead, the language for the form field should be used in the calls to those functions. A quick fix would be to test for the "body" field and set the field language to "en" in the check_rule function. A more elegant solution would be to parse out the language from the form field in the states_validate function and then pass it to the check_rule function.

A most elegant solution would be to create a new field for the Publication Abstract to replace the "body" field and have its name conform to all other ercore field names. This would require moving data that has already been entered into the database to the new field.