0

I have a "normal" Controller for an object called Application. This object has become quite complex and uses ajax-validations and lots of jQuery-functions to validate property-values and so on. Unfortunately, I am occasionally getting errors from the processAction, telling me the necessary param $newApplication is not set.

Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1298012500: 
Required argument "newApplication" is not set for 
VENDOR\myExt\Controller\ApplicationController->process

The new application object is being passed from the newAction to the fluid template just like it is shown in the Blog/Post example of the TYPO3-docbase.

Unfortunately, I am stuck finding the reason, why the process action does not get the application object from the form correctly, since it occurs occasionally (getting the error in the logs on a productive system) but I can`t reproduce it on my own testclient, where everything works as expected with different browsers. Also, the form is public, so i think it is not a problem related to accessrights etc.

Any hint on how to effectively debug this situation would be extremely helpful. Thanks in advance, Oliver

Additional info & code :

<v:variable.set name="nationalityoptions" value="{v:variable.convert(value: {}, type: 'array')}" />

<div id="bewerbungsformcontent"  class="customerform">
<f:form id="newApplicationForm" name="newApplication" extensionName="myExt" object="{newApplication}" objectName="newApplication" controller="Application" action="process" enctype="multipart/form-data" method="post">
<div name="personaldatadiv" id="personal_data_div" class="applicationform_block_div">
        <h3><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:personaldata-fieldset-title"/></h3>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-title" /></label>
        <f:form.select id="applicationform_genderselect" name="title" class="form_select" property="title" options="{vendor:TcaOptions(property: 'title', subject: 'Car24\\Car24\\Domain\\Model\\Application')}" value="0" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-salutation" /></label>
        <f:form.select id="applicationform_salutationselect" name="salutation" class="form_select" property="salutation" options="{vendor:TcaOptions(property: 'salutation', subject: 'Car24\\Car24\\Domain\\Model\\Application')}" value="0" /></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-forename" /></label>
        <f:form.textfield id="applicationform_forenameinput" name="forename" class="form_textinput" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-forename')}" property="forename" value="" required="true" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-name" /></label>
        <f:form.textfield id="applicationform_nameinput" name="name" class="form_textinput" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-name')}" property="name" value="" required="true" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-postalcode" /></label>
        <f:form.select options="{}" id="applicationform_postalnumberinput" name="addressPostalCity" class="form_select select2_plz" value="" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-street" /></label>
        <f:form.textfield id="applicationform_streetinput" name="addressStreet" class="form_select" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-street')}" property="addressStreet" value="" required="true" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-housenumber" /></label>
        <f:form.textfield id="applicationform_housenumberinput" name="addressNumber" class="form_textinput" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-housenumber')}" property="addressNumber" value="" required="true" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-country" /></label>
        <f:form.textfield id="applicationform_countryinput" name="addressCountry" class="form_textinput_readonly" property="addressCountry" required="true" value="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-country-germany')}" readonly="true" tabindex="-1" /><span class="required">*</span></p>
        <p><label for=""><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-birthdate" /></label>
        <f:form.textfield id="applicationform_birthdateselect" name="dateselect" class="form_dateselect" placeholder="dd.mm.yyyy" required="true" value="" /><span class="required">*</span></p>
        <p><label id="applicationform-label-reference" for="applicationform-referencenumber"><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-origin" /></label>
        <f:form.select id="applicationform_originselect" name="nationality" class="form_select" property="nationality" options="{vendor:TcaOptions(property: 'nationality', subject: 'Car24\\Car24\\Domain\\Model\\Application')}"/><span class="required">*</span></p>
        <h3><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationinfo-fieldset-contactinfo"/></h3>
        <h5><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-phoneinfo"/></h5>
        <p><label for="applicationform_phonecodeinput"><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-phone" /></label>
        <f:form.textfield id="applicationform_phonecodeinput" name="contactPhoneCode" property="contactPhoneCode" class="form_textinput" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-phonecode')}" value="" />
        <f:form.textfield id="applicationform_phoneinput" name="contactPhone" property="contactPhone" class="form_textinput" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-phone-number')}" value="" /><span class="required">*</span></p>
        <p><label for="applicationform_mobileinput"><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-mobile" /></label>
        <f:form.textfield id="applicationform_mobileinput" name="contactMobile" class="form_textinput" property="contactMobile" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-mobile')}" value="" /><span class="required">*</span></p>
        <p><label for="applicationform_mailinput"><f:translate key="LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-mail" /></label>
        <f:form.textfield type="email" id="applicationform_mailinput" name="contactMail" class="form_textinput" property="contactMail" placeholder="{f:translate(key: 'LLL:EXT:vendor/Resources/Private/Language/locallang_applicationform.xlf:applicationform-mail')}" value="" required="true" /><span class="required">*</span></p>
    </div>
</f:form>
</div>
Oliver
  • 105
  • 13
  • Can you please provide us your f:form and some f:form-elements tags from your form? – Paul Beck Feb 09 '18 at 09:53
  • sure ! info has been updated – Oliver Feb 09 '18 at 09:54
  • unfortunately the object has become quite sophisticated already, and I have to add a facebook-campaign-pixel as additional header data, which I add to the header inside the newAction of the controller. Currently I suspect something related to javascript/jquery problems under specific circumstances, that I couldnt reproduce/find out yet. All the property data is being mapped correctly in my tests, and I checked every form input – Oliver Feb 09 '18 at 10:02
  • 1
    Source code is mixing `property` and `name` usage on `f:form.*` components, this may behave differently than what you expect: using `property` means you're referring to an object property which means Extbase can do things like validate, and the value gets set on that property (HTML field name is auto-nested in object name wrapper). When you use `name` however this means you're creating a completely new controller argument, not a property on an object. For every `name` usage you must have a corresponding argument on the action, or the value will simply be dropped. – Claus Due Feb 09 '18 at 10:10
  • thanks a bunch. Just tidying the form up now =) – Oliver Feb 09 '18 at 10:29

1 Answers1

1

Most likely, you have one of the following problems:

  • Your controller action requires an object as argument but in your f:form you have not set the object name or it is set to the wrong name.
  • Your form posts to a controller action in a different plugin but you did not specify the target plugin name, so the request arguments do not get read by the receiving plugin.
  • You are posting data which cannot be mapped to the right target object type; for example the data may be incomplete or you are posting a object identifier which does not exist.
  • You redirect somewhere, to an action that requires an argument, but do not include the argument.

Most of these boil down to how you constructed your template. Rule of thumb: keep as many of the form components using the object and property attributes instead of manually crafting your field names.

Debugging $this->request when this failure happens may yield more information such as missing argument values or source action in case redirection happened.

Further information can only be provided if you post your template code (specifically, everything inside and including the f:form tag). FYI, the use of ajax validation may also cause desync between the actual validation requirements and the validation you perform - so a seemingly valid object may not be valid when it gets mapped and validated by your controller. Note that any override you do in your controller may also have an effect on the behavior of for example validation and argument mapping.

EDIT: clearly, from the source code you posted above you are using custom form property names instead of using object property. This will indeed have an effect on controller argument mapping: your fields will be passed as individual post fields, not properties on an object.

Claus Due
  • 4,166
  • 11
  • 23
  • 1
    If your JS is doing anything to manipulate the DOM before submission, that can be the cause for problems. You should not mix `name` and `property` (IIRC, `property` will take priority and anything you write in `name` has no effect). I really do suspect that in the edge case that occurs, something is manipulating the input in a way that yields validation or mapping errors. You can't really debug that (except to inspect the Request as mentioned) - but what you can debug, is the part of your JS or XHR which may be changing field values or otherwise modifying the DOM of the form. – Claus Due Feb 09 '18 at 10:21
  • 1
    If you turn to Request debugging, pay special attention to the way arguments are nested in the raw request (the controller argument name as wrapper). You may find the values in the wrong place when your case happens. – Claus Due Feb 09 '18 at 10:22
  • Actually I am still unable to really "debug" => the controller-action is not being executed if the parameter is not of the correct object type, so how may I dump the send values !? – Oliver Feb 12 '18 at 08:15
  • Dig down further in the ActionController / AbstractController classes and debug from there. You will need to debug code points that get executed before your action is called but after argument mapping has happened. – Claus Due Feb 13 '18 at 11:58