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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

ComplexTableField content


5 Posts   530 Views


14 July 2011 at 9:29am (Last edited: 14 July 2011 9:45am), Community Member, 28 Posts

Hello everyone. I have a question, I know how I have to do that when I add data in a table does not add inches to the other pages too, meaning that each record is displayed only in that table. Thank you very much, I leave the code:


class NuevoEquipo extends NuevaZona {

static $db = array(
'Pos' => 'Int',
'PJ' => 'Int',
'PG' => 'Int',
'PE' => 'Int',
'PP' => 'Int',
'GF' => 'Int',
'GC' => 'Int',
'DG' => 'Int',
'Puntos' => 'Int',
'Nro' => 'Int'//,
// 'Nombre' => 'text',
// 'PJ_jugad' => 'Int',
// 'PG_jugad' => 'Int',
// 'PE_jugad' => 'Int',
//'PP_jugad' => 'Int',
//'Goles' => 'Int',
//'Prom' => 'Int',
//'Tarj_a' => 'Int',
//'Tarj_r' => 'Int'

    //static $has_many = array(
    //'Equipo' => 'NuevoEquipo'
       static $has_many = array(
    'MiEquipo' => 'Equipos'
    // function getCMSFields_forPopup() {
//$fields = new FieldSet();

//$fields->push( new TextField( 'Nombre' ) );

//return $fields;
// }
   function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.Posicion", new FieldGroup(
new NumericField('Pos'),
new NumericField('PJ'),
new NumericField('PG'),
new NumericField('PE'),
new NumericField('PP'),
new NumericField('GF'),
new NumericField('GC'),
new NumericField('DG'),
new NumericField('Puntos')
      $playersTablefield = new HasManyComplexTableField(
'Nombre' => 'Nombre'
$playersTablefield->setAddTitle( 'jugador' );

$fields->addFieldToTab( 'Root.Content.Estadisticas', $playersTablefield );

return $fields;

class NuevoEquipo_Controller extends NuevaZona_Controller {
   public static $allowed_actions = array (


class Equipos extends DataObject {

static $db = array(
'Nombre' => 'text'

static $has_one = array(
'Teams' => 'NuevoEquipo'

function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Nombre' ) );
return $fields;


As you can see the images "Pepe" is added on every page (Equipo A, Equipo BB and the others), and what I want is to see only the page that I add, Hope your help!!!! Greetings

Attached Files

15 July 2011 at 3:48am Community Member, 528 Posts

May be easier to use the DataObjectManger module instead of using a HasManyComplexTableField :)


15 July 2011 at 4:33am Community Member, 28 Posts

solve my problem by changing the table type (hasmanycomplextablefield by complextablefield) marrow, which show in a table no longer appears in the other table but now I have another problem I can not checker my options. Monkey to seek dataobjectmanager not see results in the api, you could show me something about that object?


15 July 2011 at 3:04pm Community Member, 28 Posts

I just installed the module dataobjectmanager, but I still have the same drawback anyway thanks for the suggestion ... this module has several improvements


16 July 2011 at 1:06am Community Member, 528 Posts

If the same data is appearing on every page that means you're not associating it a page type. You need to associate whatever "pepe' is with your page. I assume NuevaZona is a data object as is NeuvoEquipo. Unless those have a has_one or has_many relation with a page all items will show anywhere that the DataObject is called