TYPO3 query equals by another table - typo3

I have TYPO3 7.6.18, and I have problem with query.
this works
public function getFiltered($offset = 0, $limit = 5){
$query = $this->createQuery();
$query->matching($query->equals('cruserId', 3));
return $query->execute();
But this not works
public function getFiltered($offset = 0, $limit = 5){
$query = $this->createQuery();
$query->matching($query->equals('cruserId.uid', 3));
return $query->execute();
this return empty. Why? I filter by condition in another table(fe_users). I need filter by uid, gender or other fields. I don't know where is a problem.
TCA:
'cruser_id' => [
'exclude' => 1,
'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:tx_fefiles_domain_model_photo.cruser_id',
'config' => [
'type' => 'inline',
'foreign_table' => 'fe_users',
'minitems' => 0,
'maxitems' => 1,
'appearance' => [
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
],
]
],
Model:
/**
* CruserId
*
* #var \Fhk\Feusersplus\Domain\Model\User
* #inject
*/
protected $cruserId;
/**
* Returns the cruserId
*
* #return \Fhk\Feusersplus\Domain\Model\User $cruserId
*/
public function getCruserId()
{
return $this->cruserId;
}
/**
* Sets the cruserId
*
* #return void
*/
public function setCruserId($cruserId)
{
$this->cruserId = $cruserId;
}
If I use cruserId.uid - it just return empty. I had specially create test ext by extension builder and make my model, tca the same, but it return empty. Help me please, good people) Do you now where is problem?

I think cruserId.uid is not your Tables fields. in TYPO3 Extabase query syntax you need to pass always feilds name like.
$query->equals($propertyName, $operand, $caseSensitive = true )
Parameters
string $propertyName The name of the property to compare against
mixed $operand The value to compare with
bool $caseSensitive Whether the equality test should be done
case-sensitive
For more infromation TYPO3 Query syntax

$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
this solved my problem

Related

TYPO3 get the user from cruser_id field

i would like to show the user who created an element. The TCA looks like this:
'ctrl' => [
'title' => 'Title',
'label' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
With getter i can get the tstamp and the crdate. But with the cruser_id this doesn't work. How can i get the user name of the user with the cruser_id?
The following example, works on TYPO3 11.5.8 and should work with TYPO3 10 as well.
First you need your getters und setters on your model (\YourVendor\YourExtension\Domain\Model\YourModel)
/**
* #var int
*/
protected int $cruserId = 0;
/**
* #return int
*/
public function getCruserId(): int
{
return $this->cruserId;
}
/**
* #param int $cruserId
*/
public function setCruserId(int $cruserId): void
{
$this->cruserId = $cruserId;
}
Then you need to add the TCA configuration for this specific field. You do not need to add it on types or anywhere else. TYPO3 just needs the configuration so it knows what to do with it.
'cruser_id' => [
'config' => [
'type' => 'input',
'size' => 10,
'max' => 255,
],
],
Last and not least, you need to map it on the right column. So under your your_extension/Configuration/Extbase/Persistence/Classes.php you need to add your Model and the property:
\YourVendor\YourExtension\Domain\Model\YourModel::class => [
'columns' => [
'cruserId' => [
'mapOnProperty' => 'cruser_id'
]
]
]
Here is a reference: TYPO3 v10 How do i get an object's crdate or the tstamp in FrontEnd
Backend User Object
If you want to get the Backend user information, the steps are the same but some changes need to be made.
Model
use TYPO3\CMS\Beuser\Domain\Model\BackendUser
/**
* #var BackendUser|null
*/
protected ?BackendUser $cruserId = null;
/**
* #return BackendUser|null
*/
public function getCruserId(): ?BackendUser
{
return $this->cruserId;
}
/**
* #param ?BackendUser $cruserId
*/
public function setCruserId(?BackendUser $cruserId): void
{
$this->cruserId = $cruserId;
}
TCA
'cruser_id' => [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'be_users',
'foreign_table_where' => 'ORDER BY username',
],
],
This will give you the following:
Hope it helped

Typo3 v10 - Content Elements in Extension Empty

I have a typo3 extension which allows to create Content Elements within the extension - in typo3 v9 it works fine but on typo3 v10 it doesn’t, when I debug in the template i got this result:
contentElements => protected TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorageprototypeobject (empty)
The Content Element is created and in the backend also correctly visible within the Dataset
I also tried to have a look at tx_news which implements a simular behaiver but I doesn’t have a clue, for me it seems that I done right but yeah … , following some code snippets I used, may you have an Idea:
In the setup.typoscript:
lib.contenttabs_fecontenttabs.contentElementRendering = RECORDS
lib.contenttabs_fecontenttabs.contentElementRendering {
tables = tt_content
source.current = 1
dontCheckPid = 1
}
In the Model (I tried to use the sam as news):
/**
* Get content elements
*
* #return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getContentElements()
{
return $this->contentElements;
}
/**
* Set content element list
*
* #param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $contentElements content elements
*/
public function setContentElements($contentElements)
{
$this->contentElements = $contentElements;
}
/**
* Adds a content element to the record
*
* #param \Moc\Contenttabs\Domain\Model\TtContent $contentElement
*/
public function addContentElement(\Moc\Contenttabs\Domain\Model\TtContent $contentElement)
{
if ($this->getContentElements() === null) {
$this->contentElements = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
$this->contentElements->attach($contentElement);
}
/**
* Get id list of content elements
*
* #return string
*/
public function getContentElementIdList()
{
return $this->getIdOfContentElements();
}
/**
* Get translated id list of content elements
*
* #return string
*/
public function getTranslatedContentElementIdList()
{
return $this->getIdOfContentElements(false);
}
/**
* Collect id list
*
* #param bool $original
* #return string
*/
protected function getIdOfContentElements($original = true)
{
$idList = [];
$contentElements = $this->getContentElements();
if ($contentElements) {
foreach ($this->getContentElements() as $contentElement) {
if ($contentElement->getColPos() >= 0) {
$idList[] = $original ? $contentElement->getUid() : $contentElement->_getProperty('_localizedUid');
}
}
}
return implode(',', $idList);
}
In the Template:
<f:cObject typoscriptObjectPath="lib.contenttabs_fecontenttabs.contentElementRendering">
{tab.contentElementIdList}
</f:cObject>
Some of the TCA Code (which seems to works fine):
'content_elements' => [
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'Content Elements',
'config' => [
'type' => 'inline',
'allowed' => 'tt_content',
'foreign_table' => 'tt_content',
'foreign_sortby' => 'sorting',
'foreign_field' => 'tx_tabs_content_elements',
'minitems' => 0,
'maxitems' => 99,
'overrideChildTca' => [
'columns' => [
'colPos' => [
'config' => [
'default' => 99
]
],
'CType' => [
'config' => [
'default' => 'textmedia'
]
]
]
],
'appearance' => [
'collapseAll' => 1,
'expandSingle' => 1,
'levelLinksPosition' => 'bottom',
'useSortable' => 1,
'showPossibleLocalizationRecords' => 1,
'showRemovedLocalizationRecords' => 1,
'showAllLocalizationLink' => 1,
'showSynchronizationLink' => 1,
'enabledControls' => [
'info' => false,
]
]
]
],
Thanks in advance!

TCA property not working

I have in my TYPO3 an object called Location where I store informations about a city, including a pdf file.
In the backend I can upload a pdf without problem, but when I try to display it, I get NULL. The value of 'pdf' in the database is not NULL, but when I debug <f:debug>{location}</f:debug> I get pdf => NULL !!!
Here is my TCA/LOCATION :
$GLOBALS['TCA']['tx_locations_domain_model_location'] = array(
'ctrl' => $GLOBALS['TCA']['tx_locations_domain_model_location']['ctrl'],
....
'columns' => array(
...
'pdf' => array(
'exclude' => 1,
'label' => 'LLL:EXT:locations/Resources/Private/Language/locallang_db.xlf:tx_locations_domain_model_location.pdf',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/pics',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 1
)
),
...
The Getter and Setter should be fine in typo3conf/ext/locations/Classes/Domain/Model/Location.php :
/**
* Returns the pdf
*
* #return \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
*/
public function getPdf() {
return $this->pdf;
}
/**
* Sets the pdf
*
* #param \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
* #return void
*/
public function setPdf(\TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf) {
$this->pdf = $pdf;
}
You can see the debug gives pdf=> NULL from below:
My pdf column is not empty :
Did I miss something ??
UPDATE :
After the answer of Pavin, I can see something in PDF, but I can't get the name of the file in href tag , maybe I need to change something after the new answer.
I can see things changed in the Database, the pdf field now is boolean. that's why maybe I get pdf0.originalResource NULL, but in the backend I can upload files and see then after save and refresh !!!:
<p><f:translate key="tx_locations_domain_model_location.downloadpdf" /> <a class="download" target="_blank" title="Initiates file download" href="{location.pdf.originalResource.publicUrl}"><f:translate key="tx_locations_domain_model_location.here" />..</a></p>
UPDATE 2
my new Model/Location.php
/**
* pdf
*
* #var string
*/
protected $pdf = NULL;
...
/**
* Returns the pdf
*
* #return string $pdf
*/
public function getPdf() {
return $this->pdf;
}
/**
* Sets the pdf
*
* #param string $pdf
* #return void
*/
public function setPdf($pdf) {
$this->pdf = $pdf;
}
My TCA/Location.php
'pdf' => array(
'exclude' => 1,
'label' => 'LLL:EXT:locations/Resources/Private/Language/locallang_db.xlf:tx_locations_domain_model_location.pdf',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/pics',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 1
)
),
You can use below TCA configuration for Doc types records. also add Getter and Setter methods in modle file.
'pdf' => array(
'exclude' => 0,
'label' => 'LLL:EXT:ext_key/Resources/Private/Language/locallang_db.xlf:label_key.files',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'pdf',
array('minitems' => 0,'maxitems' => 10),
'pdf,doc,docx'
),
),
For Model.php files.
/**
* pdf
*
*#var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
*/
protected $pdf;
initStorageObjects Methods :
protected function initStorageObjects() {
$this->files = new ObjectStorage();
parent::initializeObject();
}
Getter And Setter Method:
/**
* Returns the pdf
*
* #return ObjectStorage
*/
public function getPdf() {
return $this->pdf;
}
/**
* Sets the pdf
*
*/
public function setPdf($pdf) {
$this->pdf = $pdf;
}
See attached image for pdf name. Please add pdf title. For Pdf title you can use {location.pdf.title}
You use group as the type for saving the file in the TCA, so the property $pdf in your model must be string and not \TYPO3\CMS\Extbase\Domain\Model\FileReference
FileReference only work for FAL (File Abstraction Layer)

Validate File Extension IN Drupal 8 Entity Form

I have an Entity in Drupal 8 named visual_tracker_entity Here is my entity,
/**
* #file
* Contains \Drupal\visual_tracker\Entity\VisaulTrackerEntity.
*/
namespace Drupal\visual_tracker\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\visual_tracker\VisaulTrackerEntityInterface;
use Drupal\user\UserInterface;
/**
* Defines the Visaul tracker entity entity.
*
* #ingroup visual_tracker
*
* #ContentEntityType(
* id = "visaul_tracker_entity",
* label = #Translation("Visaul tracker entity"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\visual_tracker\VisaulTrackerEntityListBuilder",
* "views_data" = "Drupal\visual_tracker\Entity\VisaulTrackerEntityViewsData",
*
* "form" = {
* "default" = "Drupal\visual_tracker\Form\VisaulTrackerEntityForm",
* "add" = "Drupal\visual_tracker\Form\VisaulTrackerEntityForm",
* "edit" = "Drupal\visual_tracker\Form\VisaulTrackerEntityForm",
* "delete" = "Drupal\visual_tracker\Form\VisaulTrackerEntityDeleteForm",
* },
* "access" = "Drupal\visual_tracker\VisaulTrackerEntityAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\visual_tracker\VisaulTrackerEntityHtmlRouteProvider",
* },
* },
* base_table = "visaul_tracker_entity",
* admin_permission = "administer visaul tracker entity entities",
* entity_keys = {
* "id" = "id",
* "address" = "address",
* "lat"="lat",
* "lng" = "lng"
* },
* links = {
* "canonical" = "/admin/structure/visaul_tracker_entity/{visaul_tracker_entity}",
* "add-form" = "/admin/structure/visaul_tracker_entity/add",
* "edit-form" = "/admin/structure/visaul_tracker_entity/{visaul_tracker_entity}/edit",
* "delete-form" = "/admin/structure/visaul_tracker_entity/{visaul_tracker_entity}/delete",
* "collection" = "/admin/structure/visaul_tracker_entity",
* },
* field_ui_base_route = "visaul_tracker_entity.settings"
* )
*/
class VisaulTrackerEntity extends ContentEntityBase implements VisaulTrackerEntityInterface {
use EntityChangedTrait;
/**
* {#inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
'user_id' => \Drupal::currentUser()->id(),
);
}
/**
* {#inheritdoc}
*/
public function getName() {
return $this->get('name')->value;
}
/**
* {#inheritdoc}
*/
public function setName($name) {
$this->set('name', $name);
return $this;
}
/**
* {#inheritdoc}
*/
public function getAddress() {
return $this->get('address')->value;
}
/**
* {#inheritdoc}
*/
public function setAddress($address) {
$this->set('address', $address);
return $this;
}
/**
* {#inheritdoc}
*/
public function getLatittude() {
return $this->get('lat')->value;
}
/**
* {#inheritdoc}
*/
public function setLatitude($lat) {
$this->set('lat', $lat);
return $this;
}
/**
* {#inheritdoc}
*/
public function getLongitude() {
return $this->get('lng')->value;
}
/**
* {#inheritdoc}
*/
public function setLongitude($lng) {
$this->set('lng', $lng);
return $this;
}
/**
* {#inheritdoc}
*/
public function getCreatedTime() {
return $this->get('created')->value;
}
/**
* {#inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this->set('created', $timestamp);
return $this;
}
/**
* {#inheritdoc}
*/
public function getOwner() {
return $this->get('user_id')->entity;
}
/**
* {#inheritdoc}
*/
public function getOwnerId() {
return $this->get('user_id')->target_id;
}
/**
* {#inheritdoc}
*/
public function setOwnerId($uid) {
$this->set('user_id', $uid);
return $this;
}
/**
* {#inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this->set('user_id', $account->id());
return $this;
}
/**
* {#inheritdoc}
*/
public function isPublished() {
return (bool) $this->getEntityKey('status');
}
/**
* {#inheritdoc}
*/
public function setPublished($published) {
$this->set('status', $published ? NODE_PUBLISHED : NODE_NOT_PUBLISHED);
return $this;
}
/**
* {#inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the Visaul tracker entity entity.'))
->setReadOnly(TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the Visaul tracker entity entity.'))
->setReadOnly(TRUE);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the Visaul tracker entity entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['my_new_file'] = BaseFieldDefinition::create('file')
->setLabel(t('My New File'))
->setDescription(t('The name of the Visaul tracker entity entity.'))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'file',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'file',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['address'] = BaseFieldDefinition::create('string')
->setLabel(t('Address'))
->setDescription(t('The addres of the Visaul tracker entity entity.'))
->setSettings(array(
'max_length' => 250,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['lat'] = BaseFieldDefinition::create('string')
->setLabel(t('Latitiude'))
->setDescription(t('The latiitude of the Visaul tracker entity entity.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['lng'] = BaseFieldDefinition::create('string')
->setLabel(t('Longitude'))
->setDescription(t('The name of the Visaul tracker entity entity.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Visaul tracker entity is published.'))
->setDefaultValue(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The language code for the Visaul tracker entity entity.'))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 10,
))
->setDisplayConfigurable('form', TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
return $fields;
}
}
I need add validation rule for file type field. The default file type is come with .txt extension. I want to only allow .xls and .xlsx .
This is the file filed,
$fields['my_new_file'] = BaseFieldDefinition::create('file')
->setLabel(t('My New File'))
->setDescription(t('The name of the Visaul tracker entity entity.'))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'file',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'file',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Please help me.
I got the answer after digging drupal 8 core APIs.
If we're using a file field, then we can set the "file_extensions" setting. You can find out more information about a "file" type by going to the FileItem API.
$fields['my_new_file'] = BaseFieldDefinition::create('file')
->setSetting('file_extensions', 'xls xlsx');

TYPO3 Extbase fe_user UID in own model

I create a extbase Plugin in TYPO3 6.2. In one table i have a field "fuid" where i want to store the fe_users uid, to know which user can edit this record.
I set the "fuid" in createAction:
$newLocation->setFuID((int) $GLOBALS['TSFE']->fe_user->user['uid']);
This work. In the Database is the right UID.
But in the editAction:
$location->getFuID()
returns null
Why?
TCA:
fu_i_d' => array(
'exclude' => 1,
'label' => 'LLL:EXT:pitss24/Resources/Private/Language/locallang_db.xlf:tx_pitss24_domain_model_location.fu_i_d',
'config' => array(
'type' => 'select',
'items' => array (
array('',0),
),
'foreign_table' => 'fe_users',
'foreign_class' => '\TYPO3\CMS\Extbase\Domain\Model\FrontendUser',
'minitems' => 0,
'maxitems' => 1,
'size' => 10,
'appearance' => array(
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
),
),
),
In the Backend / TYPO3 is all OK!
In Model File.
/**
* feuseruid
*
* #var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $feuseruid;
// GET and SET Methods
/**
* Returns the feuseruid
*
* #return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser feuseruid
*/
public function getFeuseruid() {
return $this->feuseruid;
}
/*
* Sets the feuseruid
*
* #param string $feuseruid
* #return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser feuseruid
*/
public function setFeuseruid(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feuseruid) {
$this->feuseruid = $feuseruid;
}
In TCA File
'feuseruid' => array(
'exclude' => 1,
'label' => 'Feuser Id',
'config' => array(
'type' => 'inline',
'foreign_table' => 'fe_users',
'minitems' => 0,
'maxitems' => 1,
'appearance' => array(
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
),
),
),
In Sql.php
feuseruid int(11) unsigned DEFAULT '0' NOT NULL,
In Controller
/**
* User Repository
*
* #var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* #inject
*/
protected $userRepository;
$userObject = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
$orders->setFeuseruid($userObject);
$this->yourRepository->add($orders);
i found the Error! The extensionBuilder writes wrong Data in the Model:
the right values are:
Model:
/*
*
* #var TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $fuID = NULL;
...
...
...
/**
* Returns the fuID
*
* #return TYPO3\CMS\Extbase\Domain\Model\FrontendUser fuID
*/
public function getFuID() {
return $this->fuID;
}
/*
* Sets the fuID
*
* #param string $fuID
* #return TYPO3\CMS\Extbase\Domain\Model\FrontendUser fuID
*/
public function setFuID(TYPO3\CMS\Extbase\Domain\Model\FrontendUser $fuID) {
$this->fuID = $fuID;
}
Controller:
/**
* User Repository
*
* #var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* #inject
*/
protected $userRepository;
/**
* Den aktuell angemeldeten User auslesen
*
* #return \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
*/
public function getCurrentUser() {
if ($this->currentUser == NULL && $GLOBALS['TSFE']->fe_user->user['uid'] > 0) {
$this->currentUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
}
return $this->currentUser;
}
Hard to say without the appropriate view of your model. It's very likely, that you have a mismatch between your model and your TCA: On the one hand you are using an integer (setFuID()), on the other hand you have an object (foreign_table/foreign_class). Maybe it's working after you have adjusted this to be the same.