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.

Customising the CMS /

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

ComplexTableField content


Go to End


874 Views

Avatar
Paco728

Community Member, 28 Posts

14 July 2011 at 10:17am

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(
);

static $has_many = array(
'MiEquipo' => 'Equipos'
);

function getCMSFields() {
$fields = parent::getCMSFields();

$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;
}

}