Skip to content

Instantly share code, notes, and snippets.

@twaurisch
Created May 20, 2015 17:17
Show Gist options
  • Select an option

  • Save twaurisch/a55a3c836c0600e683e0 to your computer and use it in GitHub Desktop.

Select an option

Save twaurisch/a55a3c836c0600e683e0 to your computer and use it in GitHub Desktop.
XCLASS FormEngine.php to backport feature request #24906 for TYPO3 6.2 LTS, max. characters configuration for TCA field type "text"
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
$boot = function($packageKey) {
// ...
if (version_compare(TYPO3_branch, '7.0', '<') === TRUE) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Backend\Form\FormEngine'] = array(
'className' => 'BTU\BtuDevlib\Xclass\Backend\Form\FormEngine'
);
}
// ...
};
$boot($_EXTKEY);
unset($boot);
<?php
namespace BTU\BtuDevlib\Xclass\Backend\Form;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class FormEngine extends \TYPO3\CMS\Backend\Form\FormEngine {
/**
* Backport from TYPO3 7.x
* Changeset: 9a6a133c9aa3db73ba9983a9cdd1cd28467de03c
* Ticket: #24906
*
* @param string $table The table name of the record
* @param string $field The field name which this element is supposed to edit
* @param array $row The record data array where the value(s) for the field can be found
* @param array $PA An array with additional configuration options.
* @return string The HTML code for the TCEform field
* @deprecated since 6.2, will be removed two versions later
*/
public function getSingleField_typeText($table, $field, $row, &$PA) {
$item = parent::getSingleField_typeText($table, $field, $row, $PA);
$delim = '>';
$config = $PA['fieldConf']['config'];
$maxlengthAttribute = '';
if (isset($config['max']) && (int)$config['max'] > 0) {
$maxlengthAttribute = ' maxlength="' . (int)$config['max'] . '"';
$splitTag = GeneralUtility::trimExplode($delim, $item, FALSE, 2);
if (stripos($splitTag[0], 'maxlength') === FALSE) {
$splitTag[0] = $splitTag[0] . $maxlengthAttribute;
$item = implode($delim, $splitTag);
}
}
// Return field HTML:
return $item;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment