Oliver
Oliver

Reputation: 105

How to effectively debug TYPO3-Fluid-Form for new object?

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>

Upvotes: 0

Views: 841

Answers (1)

Claus Due
Claus Due

Reputation: 4271

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.

Upvotes: 1

Related Questions