I'm practicing on a very easy Extbase Extension and used a FlexForm to get three formula fields.
One of them is called "code" which should go to the EmbedderController.php and then to the viewer List.html.
I checked all tutorials I could find.
I don't understand how to get the FlexForm-value "code" into my Controller.
I get an empty page or don't get any value.
This is my FlexForm: Embedder.xml
<T3DataStructure>
<meta type="array">
<langChildren>0</langChildren>
<langDisable>1</langDisable>
</meta>
<ROOT>
<type>array</type>
<el>
<settings.code>
<TCEforms>
<label>Video Code</label>
<config>
<type>input</type>
<size>20</size>
<max>30</max>
<eval>trim</eval>
</config>
</TCEforms>
</settings.code>
<settings.width>
<TCEforms>
<exclude>1</exclude>
<label>Breite in Pixel</label>
<config>
<type>input</type>
<size>10</size>
<max>10</max>
<eval>trim</eval>
</config>
</TCEforms>
</settings.width>
<settings.height>
<TCEforms>
<exclude>1</exclude>
<label>Höhe in Pixel</label>
<config>
<type>input</type>
<size>10</size>
<max>10</max>
<eval>trim</eval>
</config>
</TCEforms>
</settings.height>
</el>
</ROOT>
</T3DataStructure>
And this is my EmbedderController.php
<?php
namespace HhuMediathek\Hhumediathek\Controller;
/**
* EmbedderController
*/
class EmbedderController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* embedderRepository
*
* @var \HhuMediathek\Hhumediathek\Domain\Repository\EmbedderRepository
* @inject
*/
protected $embedderRepository = NULL;
/**
* action list
*
* @return void
*/
public function listAction() {
$this->settings['code'];
}
}
And this is the viewer List.html
<f:layout name="Default" />
<f:section name="main">
<iframe width='570' height='321' style='width: 570px; height: 321px; border: 1px solid #ccc;' src='//xxx.de/embed/{code}' frameborder='0' allowfullscreen></iframe>
</f:section>
If you want to get value from form control, you can call ControlName.realValue () if it's a real type field. How to get value from control in form? If control uses data method the you are going to get the same values by calling that data method on sales line variable .
Deprecated since version 10.3: It is no longer considered best practice to use switchableControllerActions in a Flexform. The reasons for the deprecation and possible alternatives are outlined in the changelog Deprecation: #89463 - Switchable Controller Actions.
The Action method for POST operation accepts an object of the PersonModel class as parameter. The values posted from the Form inside the View are received through this parameter. Next step is to add a View for the Controller and while adding you will need to select the PersonModel class created earlier.
Flexforms can be used to store data within an XML structure inside a single DB column. Flexforms can be used to configure content elements (CE) or plugins, but they are optional so you can create plugins or content elements without using Flexforms.
Okay I could figure it out myself. For people who struggle with the same problem as I did:
My mistake was, that I didn't need the line $this->settings['code'];
in the Controller at all but write {settings.code}
in the viewer List.html instead of just {code}
. It's completly different than I read it in my book and some tutorials but this actually worked.
The assignment of the view parameter is missing. Therefore change
public function listAction() {
$this->settings['code'];
}
to
public function listAction() {
$this->view->assign('code', $this->settings['code']);
}
This way {code}
should be available in the view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With