Results 1 to 5 of 5

Thread: Cannot redeclare class tl_form_field

  1. #1

    Default Cannot redeclare class tl_form_field

    Hi,

    I want to use the functionality of the form module inside my module. The problem is that i can not extend the class tl_form as my forms need to be attached to an other element.
    I tried to adapt the DCA from tl_form with array_insert. This is working but the original tl_form is then not working anymore as it is outputting an error that it can not find tl_ff_tasks when using the form module
    This is the reason why I did the following:

    Code:
    $this->loadLanguageFile('tl_form');
    include(TL_ROOT.'/system/modules/backend/dca/tl_form.php');
    
    $GLOBALS['TL_DCA']['tl_ff_form']=$GLOBALS['TL_DCA']['tl_form'];
    
    array_insert($GLOBALS['TL_DCA']['tl_ff_form']['config']['ptable'], 1, 'tl_ff_tasks');  <== other element
    array_insert($GLOBALS['TL_DCA']['tl_ff_form']['config']['ctable'], 1, array('tl_ff_form_field')
    );
    ...... Some extra fields
    
    class tl_ff_form extends Backend
    {
    
    	/**
    	 * Import the back end user object
    	 */
    	public function __construct()
    	{
    		parent::__construct();
    		$this->import('BackendUser', 'User');
    	}
    
    	public function deleteFormButton($row, $href, $label, $title, $icon, $attributes)
    	{
    		return ($this->User->isAdmin || $this->User->hasAccess('delete', 'flexiform')) ? ''.$this->generateImage($icon, $label).' ' : $this->generateImage(preg_replace('/\.gif$/i', '_.gif', $icon)).' ';
    	}
    
    }
    Is this the correct way?
    +
    I have the following issue: When i try to delete a tl_ff_form I get the following error:
    Fatal error: Cannot redeclare class tl_form_field in /Users/freeyland/Sites/bureauguide/system/modules/backend/dca/tl_form_field.php on line 627
    Why does it keep referencing to tl_form_field?

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Cannot redeclare class tl_form_field

    if you are using Contao 2.10.x try to empty the cache (Maintenance under System)

    I've read about some issues with this new functionality
    Consulenza Contao CMS https://www.intco.it

  3. #3

    Default Re: Cannot redeclare class tl_form_field

    Thanx, but already tried

  4. #4
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Cannot redeclare class tl_form_field

    replace

    Code:
    include(TL_ROOT.'/system/modules/backend/dca/tl_form.php');
    with
    Code:
    $this->loadDataContainer('tl_form');
    Consulenza Contao CMS https://www.intco.it

  5. #5

    Default Re: Cannot redeclare class tl_form_field

    Thanx!!!! Logic, I was loading the class twice.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •