Question

I am currently trying to write a simple input form extension: the user enters the input field values, the submit action inserts the values into the database and then redirects to an external payment service.

Unfortunately, the createAction function does not show any reaction after a click on the submit button.

For test purposes, I just want to output a text after the submit. But not even that works.

If I use the exact same function of flashMessageContainer in the newAction, it works: the message is displayed immediately. But when I want to show it after a click on the submit button, nothing but a page reload happens.

What could be the problem?

Resources / Private / Templates / Payment / New.html:

<f:form method="post" controller="Payment" action="create" id="newPayment" name="newPayment" object="{newPayment}">
    <f:render partial="Payment/FormFields" />

    <div class="buttons row">
        <div class="col c6">
            <f:form.submit value="{f:translate(key:'tx_chilipayment_domain_model_payment.submit')}" />
        </div>
    </div>

    ......

Classes / Controller / PaymentController.php:

<?php
namespace chilischarf\ChiliPayment\Controller;
    class PaymentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

        /**
         * paymentRepository
         *
         * @var \chilischarf\ChiliPayment\Domain\Repository\PaymentRepository
         * @inject
         */
        protected $paymentRepository;

        /**
         * action new
         *
         * @param \chilischarf\ChiliPayment\Domain\Model\Payment $newPayment
         * @dontvalidate $newPayment
         * @return void
         */
        public function newAction(\chilischarf\ChiliPayment\Domain\Model\Payment $newPayment = NULL) {
            $this -> view -> assign('newPayment', $newPayment);
        }

        /**
         * action create
         *
         * @param \chilischarf\ChiliPayment\Domain\Model\Payment $newPayment
         * @return void
         */
        public function createAction(\chilischarf\ChiliPayment\Domain\Model\Payment $newPayment) {

            $this -> flashMessageContainer -> add('Your new Payment was created.');
        }
    }
    ?>
Was it helpful?

Solution

Usually you dont want your createAction to render anything. You just want it to validate and persist the user input and then redirect to another action, where e.g. a flash message is rendered. That being said, the problem you describe can have several causes, so I will point to a few issues you might have or your problem may be related to:

  1. Do you have a Create.html Template in Resources/Private/Templates/Payment/Create.html? This is the template the create action will render.
  2. Do you have a <f:flashMessages /> viewHelper in this template? Since you dont assgin anything to your view in your createAction (which is perfectly fine if you dont plan to render anything here, as mentioned above) this is he only "dynamically" created content.
  3. Do you reach your createAction after submitting your form? Or is something with the validation going wrong (in that case you will be redirected back to your newAction with a default flashMessage that an error occured while trying to call createAction)? You can figure that out, when you add a die(); to your createAction. After submiting you'll see a white page if your creatAction was called successfully.
  4. Is 'create' a valid action for your controller as configured in your ext_localconf.php? If not, add it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top