-->

“Map to existing tables” in Extension builder show

2020-06-19 03:15发布

问题:

In my extension MyExt, I mapped the model Page to pages table in TYPO3. Firstly it shows me the type mismatch error, I anyhow went ahead and saved it.

The following things happen:

  • My Page tree becomes like this:

  • My New Record Form shows only the UIDs and not the titles:

  • My Page Edit becomes like this:

In my MyExt/Configuration/TypoScript/setup.txt I have this:

config.tx_extbase.persistence.classes {
    Tx_MyExt_Domain_Model_Page {
        mapping {
            tableName = pages
        }
    }
}

Is this a bug ? Or something i'm doing wrong ?

This is my /Domain/Model/Page.php , just a glimpse of it.

class Page extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{

    /**
     * uid
     * @var int
     * @validate NotEmpty
     */
    protected $uid;

    /**
     * title
     * @var string
     * @validate NotEmpty
     */
    protected $title;

    /**
     * __construct
     *
     * @return Page
     */
    public function __construct() {
        //Do not remove the next line: It would break the functionality
        $this->initStorageObjects();
    }

   /**
    * Returns the title
    *
    * @return string $title
   */
  public function getTitle(){
    return $this->title;
  }

}

My /Domain/Repository/PageRepository.php is

class PageRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {

}

回答1:

Just delete the whole $TCA['pages'] section from the file my_ext/ext_tables.php, or comment it out.

If set, it overrides most default TCA settings from the TYPO3 core with values from your extension. You probably don't need custom settings for that.