Custom save method for a form via `form_action` decorator.
Example:
class CityViewSet(AngularFormMixin, viewsets.ModelViewSet):
...
form_layouts = {
'custom': ['name']
}
form_id + the same parameters as DRF's action decorator
form_action(form_id='custom', detail=False, url_path='custom', methods=['GET', 'POST'])
def custom_form_action(self, request):
if request.method == 'POST':
zipcode is a required field
request.data['zipcode'] = lookup_zipcode(request.data['city'])
return super().create(request)
return super().retrieve(request)
this.dialog.open('/api/1.0/cities/', {
formId: 'custom'
}).subscribe(result => {
console.log(result);
});