2012-12-28 36 views
0

我想使用盡可能多的標準TYPO3來創建一個表單來編輯tx_mytable中的單個記錄。TYPO3:在前端插件中使用t3lib_TCEforms

在pi1我加載該表的tca: t3lib_div :: loadTCA('tx_mytable');

現在我想用標準的函數來創建我的表單元素或多或少像它在後端做...

我發現這個前端的,但無法找到任何工作的例子: t3lib_TCEforms_fe .php(擴展了正常的t3lib_TCEforms)

這是正確的方式還是有更好的方法?

回答

0

我得到了一些工作,但在前端

這裏不是真的那麼漂亮的代碼是telss該TCA是不夠的,但陣列中的兩個新項目需要 http://www.martin-helmich.de/?p=15

這是itemFormElName鏈接和itemFormElValue

// include tceforms_fe (place outside class where pipase is included) 
require_once(PATH_t3lib.'class.t3lib_tceforms_fe.php'); 

// load TCA for table in frontend 
t3lib_div::loadTCA('tx_ogcrmdb_tasks'); 

// init tceforms 
$this->tceforms = t3lib_div::makeInstance("t3lib_TCEforms_FE"); 
$this->tceforms->initDefaultBEMode(); // is needed ?? 
$this->tceforms->backPath = $GLOBALS['BACK_PATH']; // is empty... may not be needed 

//////////REPEAT FOR EACH INPUT FIELD///////// 
// start create input fields, here just a single select for responsible 

// conf used for tceforms similar to but not exactly like normal TCA 
$conftest = array(
    'itemFormElName' => $GLOBALS['TCA']['tx_ogcrmdb_tasks']['columns']['responsible']['label'], 
    'itemFormElValue' => 1, 
    'fieldConf' => array(
     'config' => $GLOBALS['TCA']['tx_ogcrmdb_tasks']['columns']['responsible']['config'] 
    ) 
); 

// create input field 
$this->content .= $this->tceforms->getSingleField_SW('','',array(),$conftest); 

// wrap in form 
$output = '<form action="" name="editform" method="post">'; 
$output .= $this->content; 
$output .= '</form>'; 

// wrap and return output 
return $output; 

仍然在尋找一個可用於輸入字段的custem模板的工作示例。