# Add new Field Properties ## Introduction You can extend powermail fields with new properties to insert (e.g.) a checkbox for readonly or disabled or something else. Following example shows two new fields in a new tab "Powermailextended". The first is an input field of type textarea. If the user entered text for this field this text shall be displayed. The second field is a checkbox. If this checkbox was checked from an editor, the input field should use the html-attribute readonly="readonly". ![developer_new_fieldproperties1](../Images/developer_new_fieldproperties1.png) ![developer_new_fieldproperties2](../Images/developer_new_fieldproperties2.png) ## Extend powermail with an own extension You have to add one or more fields into tx_powermail_domain_model_field, describe it with additional TCA, add new Models and change the HTML-Template as you want. You can add a new extension with an example key powermailextended. EXT:powermailextended/ext_tables.sql: ``` # # Table structure for table 'tx_powermail_domain_model_field' # CREATE TABLE tx_powermail_domain_model_field ( tx_powermailextended_powermail_text varchar(255) DEFAULT '' NOT NULL, tx_powermailextended_powermail_readonly tinyint(4) unsigned DEFAULT '0' NOT NULL ); ``` EXT:powermailextended/ext_tables.php: ``` array( 'exclude' => 1, 'label' => 'Text before field', 'config' => array ( 'type' => 'text', 'cols' => '32', 'rows' => '2' ) ), 'tx_powermailextended_powermail_readonly' => array( 'exclude' => 1, 'label' => 'Readonly', 'config' => array ( 'type' => 'check' ) ), ); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns( 'tx_powermail_domain_model_field', $tempColumns ); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( 'tx_powermail_domain_model_field', '--div--;Powermailextended, tx_powermailextended_powermail_text, tx_powermailextended_powermail_readonly', '', 'after:own_marker_select' ); ``` EXT:powermailextended/Configuration/TypoScript/setup.txt: ``` # Add own Partials plugin.tx_powermail.view { partialRootPaths { 1 = EXT:powermailextended/Resources/Private/Partials/ } } # Add new Field Properties config.tx_extbase{ persistence{ classes{ In2code\Powermail\Domain\Model\Form { subclasses { 0 = In2code\Powermailextended\Domain\Model\Form } } In2code\Powermail\Domain\Model\Page { subclasses { 0 = In2code\Powermailextended\Domain\Model\Page } } In2code\Powermail\Domain\Model\Field { subclasses { 0 = In2code\Powermailextended\Domain\Model\Field } } In2code\Powermailextended\Domain\Model\Form { mapping { tableName = tx_powermail_domain_model_form } } In2code\Powermailextended\Domain\Model\Page { mapping { tableName = tx_powermail_domain_model_page } } In2code\Powermailextended\Domain\Model\Field { mapping { tableName = tx_powermail_domain_model_field } } } } objects { In2code\Powermail\Domain\Repository\FormRepository.className = In2code\Powermailextended\Domain\Repository\FormRepository } } ``` EXT:powermailextended/Resources/Private/Partials/Form/Field/Input.html: ``` {namespace vh=In2code\Powermail\ViewHelpers}

{field.txPowermailextendedPowermailText}

``` EXT:powermailextended/Classes/Domain/Model/Field.php: ``` txPowermailextendedPowermailReadonly = $txPowermailextendedPowermailReadonly; } /** * @return string */ public function getTxPowermailextendedPowermailReadonly() { return $this->txPowermailextendedPowermailReadonly; } /** * @param string $txPowermailextendedPowermailText * @return void */ public function setTxPowermailextendedPowermailText($txPowermailextendedPowermailText) { $this->txPowermailextendedPowermailText = $txPowermailextendedPowermailText; } /** * @return string */ public function getTxPowermailextendedPowermailText() { return $this->txPowermailextendedPowermailText; } } ``` EXT:powermailextended/Classes/Domain/Model/Page.php: ``` */ protected $fields = NULL; /** * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $fields * @return void */ public function setFields($fields) { $this->fields = $fields; } /** * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage */ public function getFields() { return $this->fields; } } ``` EXT:powermailextended/Classes/Domain/Model/Form.php: ``` */ protected $pages; /** * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $pages * @return void */ public function setPages($pages) { $this->pages = $pages; } /** * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage */ public function getPages() { return $this->pages; } } ``` EXT:powermailextended/Classes/Domain/Repository/FormRepository.php: ```