Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » ComplexTableField content

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

Page: 1
Go to End
Author Topic: 509 Views
  • Paco728
    Avatar
    Community Member
    28 Posts

    ComplexTableField content Link to this post

    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
  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: ComplexTableField content Link to this post

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

  • Paco728
    Avatar
    Community Member
    28 Posts

    Re: ComplexTableField content Link to this post

    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?

  • Paco728
    Avatar
    Community Member
    28 Posts

    Re: ComplexTableField content Link to this post

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

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: ComplexTableField content Link to this post

    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

    509 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.