[TYPO3-dev] BE Module: How to add a datepicker to an input

Stephen Bungert stephenbungert at yahoo.de
Thu Nov 17 21:36:51 CET 2011


I aslo need this and after looking at the tce forms I found I could create 
this quite easily just by adding span tag before the field and then wrapping 
everything in another span tag.

I just started recreating my fiedls so that they all use this, and have 
created a basic fuction to create them:



 function createClearableTextField($numOfFields = 1) {
  $titleText  = $GLOBALS['LANG']->getLL('titletext_manifestCreateField');
  $fieldSuffix = 'NewFields';
  $fields   = '';

  for ($index = 0; $index <= $numOfFields; $index ++) {
   $suffix = $fieldSuffix;

   if ($numOfFields > 1) {
    $suffix = 'NewFields[' . $index . ']';
   }

   $fields .=  '<span 
onmouseout="this.className=\'t3-tceforms-input-wrapper\';" onmouseover="if 
(document.getElementById(\'' . $this->type . $suffix . '\').value) 
{this.className=\'t3-tceforms-input-wrapper-hover\';} else 
{this.className=\'t3-tceforms-input-wrapper\';};" 
class="t3-tceforms-input-wrapper">
       <span onclick="document.getElementById(\'' . $this->type . $suffix . 
'\').value=\'\';document.getElementById(\'' . $this->type . $suffix . 
'\').focus();" class="t3-icon t3-icon-actions t3-icon-actions-input 
t3-icon-input-clear t3-tceforms-input-clearer" tag="a">&nbsp;</span>
       <input title="' . $titleText . '" value="" class="formField3 
tceforms-textfield tx_sbportfolio_textField" name="' . $this->type . $suffix 
. '" id="' . $this->type . $suffix . '" type="text" />
      </span>';
  }

  return $fields;
 }

You can alter it to suit your needs, like the input names/ids ($this->type . 
$suffix - probably not much use to you) and remove any classes that begin 
with "tx_sbportfolio", they are just for my own styling.

Using the above I now have the clear field "x" that appears on mouse over 
when the field contains a value.

Hope this helps 




More information about the TYPO3-dev mailing list