Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Filters in complexTableField (Solved)

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

Page: 1
Go to End
Author Topic: 691 Views
  • santosmateo
    Avatar
    Community Member
    11 Posts

    Filters in complexTableField (Solved) Link to this post

    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

  • santosmateo
    Avatar
    Community Member
    11 Posts

    Re: Filters in complexTableField (Solved) Link to this post

    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

    691 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.