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 /

Filters in complexTableField (Solved)


Reply


2 Posts   732 Views

Avatar
santosmateo

Community Member, 11 Posts

2 August 2011 at 6:17am

Hi, I'm new Siverstripe, and I have some doubts about the management of complextablefield.

I'm trying to add a filter, but I am unable to make it work ...

The result I want is that only appear in the CMS data for each project, rather than data from across the table.

I tried with a filter inside complexTablefield, and I've tried to create a record with the ID of the project within the rows and then create a filter based on this information, but I am unable to work.

My code:

class arqnProyecto extends Page {

static $many_many = array(
'datosProyecto' => 'arqnDatos'
);

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

$ table = new ComplexTableField (
$ this,
'datosProyecto'
'arqnDatos'
array (
'Details' => 'Details'
'Location' => 'Location',
'Thumb' => 'Image'
), 'GetCMSfields_forPopup'
"arqnDatos = '$ this -> ID'" / / FILTER, BUT NO WORKS
/ / null,
/ / null,
"arqnDatos.Proyecto", $ this-> ID / / SAVE ID FROM PROJECT BUT ALSO NO WORKS :(
);

Any help is good.

Thank you very much!

Carlos

Avatar
santosmateo

Community Member, 11 Posts

2 August 2011 at 4:06pm

Hello again, finally I find the answer:

arqnproyecto.php:

<?php
class arqnProyecto extends Page {

static $many_many = array(
'datosProyecto' => 'arqnDatos'
);

function getCMSFields(){

$fields = parent::getCMSFields();

$tabla = new ComplexTableField(
$this,
'datosProyecto',
'arqnDatos',
array(
'Detalles' => 'Detalles',
'Localizacion' => 'Localizacion',
'Thumb' => 'Imagen'
),'getCMSfields_forPopup',
"`proyectoID` = '{$this->ID}'" // FILTER
);

$fields->addFieldToTab('Root.Content.Proyecto',$tabla);

return $fields;
}
}
class arqnProyecto_Controller extends Page_Controller {}

Where proyectoID comes from:

arqndatos.php:

class arqnDatos extends DataObject {

// Crea un a tabla con tres columnas
static $db = array(
// 'Proyecto' => 'Text',
// 'Proyecto' => 'Int' ,
'Detalles' => 'Text',
'Localizacion' => 'Text',

);

static $has_one = array(
'imagenesProyecto' =>'Image',
'proyecto' => 'arqnProyecto'
);

......
}

thanks!

Carlos