1

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!

3 Answers 3

2

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);
Sign up to request clarification or add additional context in comments.

Comments

1

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;  
    }

Comments

0

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.

3 Comments

the protected Value from $location is null too. It don't load the value from the Database. I don't know why the extensionBuilder named sometime the functions fuid but the mysql field is fu_i_d, and where is the mapping from both?
Mapping happens (under normal circumstances) automatically if coding convention is followed. lowerCamelCase get's converted to lower_cased_underscored (lowerCase => lower_case) and vice versa.
What you need for Information? I have the same Error on an other Plugin from this extension too. The most things are default from the extension manager. I don't have an idea where i could found this error.

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.