Git Product home page Git Product logo

silverstripe-gridfieldeditablemanymanyextracolumns's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

silverstripe-gridfieldeditablemanymanyextracolumns's Issues

Extra fields not stored :(

Hi Andreas,

storing extra fields doesn't work (with autosave on or off).

Look at my code:

class Billboard extends DataObject {

    static $db = array (
        'Cislo' => 'Varchar(127)',
        'Popis' => 'Text'
    );

    static $has_one = array(
        'Foto' => 'Image'
    );

    static $many_many = array (
        'Objednavky' => 'Objednavka',
    );

    static $many_many_extraFields = array(
    'Objednavky' => array(
        'StartDate' => 'Varchar',
        'EndDate' => 'Varchar'
    ),
    );

    static $searchable_fields = array(
        "Cislo"
    );

    static $summary_fields = array(
        'Cislo'
   );

    static $description = 'Zoznam billboardov';

    function getCMSFields() {

        $fields = parent::getCMSFields();

        if ($this->ID) {
            // add my custom formfield for subprojects
            $config = GridFieldConfig_RelationEditor::create();
            $config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Cislo'))->setResultsFormat('$Cislo');
            $gridField = new GridField("Objednavky", "Objednavky", $this->Objednavky(), $config);
            $fields->addFieldToTab("Root.Objednavky", $gridField);
            $component = new GridFieldEditableManyManyExtraColumns();
            $component->setSaveAutomatically(false);
            $fields->dataFieldByName('Objednavky')->getConfig()->addComponent($component, 'GridFieldEditButton');
            //$fields->addFieldToTab("Root.Extra", new TextField('ManyMany[StartDate]', 'Start'));
        } else {
            $fields->addFieldToTab("Root.Objednavky", new LiteralField("objnote","Objednavku pridáte po prvom uložení"));
        }

        return $fields; 
    }

}

and

class Objednavka extends DataObject {

    static $db = array (
        'Cislo' => 'Varchar(127)',
        'Popis' => 'Text'
    );

    static $has_one = array(
        'Zakaznik' => 'Zakaznik'
    );

    static $belongs_many_many = array (
        'Billboardy' => 'Billboard',
    );

    static $searchable_fields = array(
        "Cislo"
    );

    static $summary_fields = array(
        'Cislo'
   );

    function getCMSFields() {

        $fields = parent::getCMSFields();

        if ($this->ID) {
            // add my custom formfield for subprojects
            $config = GridFieldConfig_RelationEditor::create();
              $config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchFields(array('Cislo'))->setResultsFormat('$Cislo');
            $gridField = new GridField("Billboardy", "Billboardy", $this->Billboardy(), $config);
            $fields->addFieldToTab("Root.Billboardy", $gridField);
            $component = new GridFieldEditableManyManyExtraColumns();
            $component->setSaveAutomatically(false);
            $fields->dataFieldByName('Billboardy')->getConfig()->addComponent($component, 'GridFieldEditButton');
        } else {
            $fields->addFieldToTab("Root.Billboardy", new LiteralField("billnote","Billboardy pridáte po prvom uložení"));
        }

        return $fields; 
    }

 }

Any idea what is wrong? Im using SS 3.0.3.

Best regards

Pali

Not working in SS 3.1

This seems to be a very useful module, and I don't understand why this hasn't been picked up more.
I was hesitant trying it because it didn't have a composer.json file, and it actually doesn't work in 3.1. See screenshot.

I'd love to help getting it going, but am having issues wrapping my head around some of the code - maybe we could make this a shared (or sponsored) effort?

screenshot 2015-05-16 09 22 00

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.