class ApplicationAjaxController {

    @PostMapping("/{competitionId}/saveFormElement")
    @ResponseBody
    public JsonNode saveFormElement(@RequestParam("formInputId") String inputIdentifier,
                                    @RequestParam("value") String value,
                                    @RequestParam("multipleChoiceOptionId") Long multipleChoiceOptionId,
                                    @PathVariable(APPLICATION_ID) Long applicationId,
                                    @PathVariable("competitionId") Long competitionId,
                                    UserResource user,
                                    HttpServletRequest request) {
        List<String> errors = new ArrayList<>();
        Long fieldId = null;
        try {
            String fieldName = request.getParameter("fieldName");
            LOG.info(String.format("saveFormElement: %s / %s", fieldName, value));

            StoreFieldResult storeFieldResult = storeField(applicationId, user.getId(), competitionId, fieldName, inputIdentifier, value, multipleChoiceOptionId);

            fieldId = storeFieldResult.getFieldId();

            return createJsonObjectNode(true, fieldId);

        } catch (Exception e) {
            AutoSaveElementException ex = new AutoSaveElementException(inputIdentifier, value, applicationId, e);
            handleAutoSaveException(errors, e, ex);
            return createJsonObjectNode(false, fieldId);
        }
    }

}