1

Inside my extbase extension I have an appointment model and users can write feedback to how the appointment was.
So I created a feedback model with different fields.
Now what should I implement for when the user clicks on the "Create Feedback" button?
So far I got this, but it's not working:

<f:link.action action="edit" controller="Feedback" arguments="{appointment:appointment}">

I get the the error:

Argument 1 passed to ...Controller\FeedbackController::newAction() must be an instance of ...\Model\Appointment, none given

FeedbackController:

     /**
     * action new
     * @param ...\Domain\Model\Appointment $appointment
     * @return void
     */
    public function newAction(...\Domain\Model\Appointment $appointment) {
        $this->view->assign('appointment', $appointment);
    }

Why do I get this error? (the appointment object was definitely there, I debugged it)
I figure it must've something to do with the switch from AppointmentController to FeedbackController.

What's the best way to implement this?

1
  • 1
    How does the generated link look like? Is there a appointment uid present? Is your plugin/controller allowed to access the storage folder that holds the appointment record? Commented Nov 4, 2016 at 18:33

3 Answers 3

4

You need the pluginName parameter in your link generation if you use different plugins.

<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}">

When generating a link TYPO3 prepends the "namespace" of the argument to the link like this: tx_myplugin[action]=new. Make sure, that the pluginName is the same one you defined in ext_localconf.php. In this case the pluginName would be your_plugin.

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Vendor.' . $_EXTKEY,
    'your_plugin',
    array(
        'Feedback' => 'new',
    ),
    // non-cacheable actions
    array(
        'Feedback' => '',
    )
);
Sign up to request clarification or add additional context in comments.

1 Comment

I think I also need it in my case - Without using different plugins?! Because it really was the reason it wasn't working apparently even though I'm just using one plugin (I think) :) thanks!
0

Check the plugin-controller-action array in your ext_localconf.php and post it. Maybe there is something wrong.

Comments

0

If you get this error :

Argument 1 passed to ...Controller\FeedbackController::newAction() must be an instance of ...\Model\Appointment, none given

it's because you give the controler a NULL object and taht's not allowed with your controller.

To avoid this error, you could allow NULL object in your controller :

   /**
     * action new
     * @param ...\Domain\Model\Appointment $appointment
     * @return void
     */
    public function newAction(...\Domain\Model\Appointment $appointment=NULL) {
        $this->view->assign('appointment', $appointment);
    }

this is weird because in your link, you call an action 'edit' and you have an error in 'newAction' controller instead of 'editAction' controller, you should have the 'edit' action allowed for your plugin (cachable or not) :

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Vendor.' . $_EXTKEY,
    'your_plugin',
    array(
        'Feedback' => 'edit',
    ),
    // non-cacheable actions
    array(
        'Feedback' => 'edit',
    )
);

and as Natalia wrote add the plugin name if the action you want to call belongs to another plugin.

<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}">

Florian

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.