Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

ComplexTableField: Why don't work?


Go to End
Reply


3 Posts   1352 Views

Avatar
biapar

Forum Moderator, 435 Posts

18 October 2010 at 5:58am

Edited: 18/10/2010 5:59am

Hi,

I've into a class extends LeftAndMain
....
function getEditForm() {

$editor = new ComplexTableField(
$this,
'ContactFormSubmissions',
'ContactFormSubmission',
array('Name','Surname'),

);
$editor->setParentClass(false);

$myTableField= ...

$fields= new FieldSet($myTableField,$editor);

$actions = new FieldSet(
new FormAction('doSaveLink', 'Salva')
);

$form = new Form($this, "EditForm", $fields, $actions,null);

return $form;
}
function ContactFormSubmissions() {
return DataObject::get('ContactFormSubmission');
}

}

but at runtime I've thie error:

[Notice] Array to string conversion

Trace

    * strpos(Array,()
      Line 268 of ViewableData.php
    * ViewableData->castingClass(0)
      Line 374 of ViewableData.php
    * ViewableData->obj(0,,,)
      Line 446 of ViewableData.php
    * ViewableData->XML_val(0)
      Line 1341 of TableListField.php
    * TableListField_Item->Fields()
      Line 369 of ViewableData.php
    * ViewableData->obj(Fields)
      Line 589 of .cacheC..xampp.htdocs.ss242.sapphire.templates.ComplexTableField.ss
    * include(C:\Windows\Temp\silverstripe-cacheC--xampp-htdocs-ss242\.cacheC..xampp.htdocs.ss242.sapphire.templates.ComplexTableField.ss)
      Line 420 of SSViewer.php
    * SSViewer->process(ComplexTableField)
      Line 342 of ViewableData.php
    * ViewableData->renderWith(ComplexTableField)
      Line 275 of ComplexTableField.php
    * ComplexTableField->FieldHolder()
      Line 369 of ViewableData.php
    * ViewableData->obj(FieldHolder,,,1)
      Line 446 of ViewableData.php
    * ViewableData->XML_val(FieldHolder,,1)
      Line 77 of .cacheC..xampp.htdocs.ss242.sapphire.templates.Includes.Form.ss
    * include(C:\Windows\Temp\silverstripe-cacheC--xampp-htdocs-ss242\.cacheC..xampp.htdocs.ss242.sapphire.templates.Includes.Form.ss)
      Line 420 of SSViewer.php
    * SSViewer->process(Form)
      Line 342 of ViewableData.php
    * ViewableData->renderWith(Array)
      Line 1085 of Form.php
    * Form->forTemplate()
      Line 447 of ViewableData.php
    * ViewableData->XML_val(EditForm,,1)
      Line 12 of .cacheC..xampp.htdocs.ss242.mysite.code.templates.DispoAdmin_right.ss
    * include(C:\Windows\Temp\silverstripe-cacheC--xampp-htdocs-ss242\.cacheC..xampp.htdocs.ss242.mysite.code.templates.DispoAdmin_right.ss)
      Line 420 of SSViewer.php
    * SSViewer->process(DispoAdmin)
      Line 342 of ViewableData.php
    * ViewableData->renderWith(Array)
      Line 485 of LeftAndMain.php
    * LeftAndMain->Right()
      Line 369 of ViewableData.php
    * ViewableData->obj(Right,,,1)
      Line 446 of ViewableData.php
    * ViewableData->XML_val(Right,,1)
      Line 71 of .cacheC..xampp.htdocs.ss242.cms.templates.LeftAndMain.ss
    * include(C:\Windows\Temp\silverstripe-cacheC--xampp-htdocs-ss242\.cacheC..xampp.htdocs.ss242.cms.templates.LeftAndMain.ss)
      Line 420 of SSViewer.php
    * SSViewer->process(DispoAdmin)
      Line 202 of Controller.php
    * Controller->handleAction(SS_HTTPRequest)
      Line 137 of RequestHandler.php
    * RequestHandler->handleRequest(SS_HTTPRequest)
      Line 147 of Controller.php
    * Controller->handleRequest(SS_HTTPRequest)
      Line 281 of Director.php

Why? Thank you

Avatar
biapar

Forum Moderator, 435 Posts

19 October 2010 at 1:01am

?

Avatar
AlphaCactus

Community Member, 11 Posts

4 December 2011 at 5:26pm

The way I figured out where the problem was, was do temporarily add

Debug::show( $child );
Debug::show( $name );
Debug::show( $child->Name() );

to the dataFieldByName function that was throwing the error. That quickly showed me that somehow one of my field names was in fact totally screwed up and also coincidentally an array.