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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

ComplexTableField content


Go to End


5 Posts   869 Views

Avatar
Paco728

Community Member, 28 Posts

14 July 2011 at 9:29am

Edited: 14/07/2011 9:45am

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:

NuevoEquipo.php

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(
$this,
'MiEquipo',
'Equipos',
array(
'Nombre' => 'Nombre'
),
'getCMSFields_forPopup'
);
$playersTablefield->setAddTitle( 'jugador' );

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

return $fields;
}

}

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

Equipo.php

<?php
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
Avatar
zenmonkey

Community Member, 545 Posts

15 July 2011 at 3:48am

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

Avatar
Paco728

Community Member, 28 Posts

15 July 2011 at 4:33am

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?

Avatar
Paco728

Community Member, 28 Posts

15 July 2011 at 3:04pm

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

Avatar
zenmonkey

Community Member, 545 Posts

16 July 2011 at 1:06am

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