Afform dies for contacts if no ID or contact_type
A second slightly weird Afform edge case I hit today.
Example afform:
<af-form ctrl="afform">
<af-entity data="{source: 'Enquiry form'}" type="Contact" name="Contact1" label="Contact email" actions="{create: true, update: true}" security="RBAC" />
<fieldset af-fieldset="Contact1" class="af-container" af-title="Contact">
<p class="af-text">Follow up contact email</p>
<div af-join="Email" data="{is_primary: true}">
<af-field name="email" />
</div>
</fieldset>
<button class="af-button btn btn-primary" crm-icon="fa-check" ng-click="afform.submit()" ng-if="afform.showSubmitButton">Submit</button>
</af-form>
The form gives on submit "No contact_type given to CRM_Contact_BAO_Contact::hasName".
It looks like the Afform api Submit action is trying to check whether a submitted contact entity has a name OR email (so is creatable) - but the name check throws an exception if no contact_type is provided - even if there was a viable email.
Potentially having a Contact entity without a specified contact_type is a bad idea ... but I can see a use case like the above where you want people to be able to submit an email, that might then be deduped against contacts of any type? (Testing now I realise this doesn't work out-of-the-box because deduping is within contact types... but you might have some later hooks onto the submit event to deal with this maybe...?)
Potential patch incoming at any rate.