rainlab / builder-plugin

Visual development tool for October CMS
Other
171 stars 61 forks source link

identifierValue in plugins\rainlab\builder\components\RecordDetails.php #347

Closed schillerenrico closed 3 years ago

schillerenrico commented 3 years ago

Hello!

I am currently trying your components for list and detailpages. It accured that the $identifierValue in RecordDetails.php is not returning the value in the url but instead the key name. I followed this tutorial (https://octobercms.com/support/article/ob-12) but the value of $identifierValue is always just the key name and this results in record not found from this method.

    protected function loadRecord()
    {
       /**
        * just testing code
        * print_r($this->identifierValue); // just for testing what value is present here and it prints "slug" instead of the value from the url
        * die();
        */
        if (!strlen($this->identifierValue)) {
            return;
        }

        $modelClassName = $this->property('modelClass');
        if (!strlen($modelClassName) || !class_exists($modelClassName)) {
            throw new SystemException('Invalid model class name');
        }

        $model = new $modelClassName();
        return $model->where($this->modelKeyColumn, '=', $this->identifierValue)->first();
    }

If you need more to replicate the issue, pls let me know

LukeTowers commented 3 years ago

@schillerenrico please post the configuration of the component from the page / layout where you have included the component.

schillerenrico commented 3 years ago

I just found my mistake. The configuration was a good hint. I messed up the identifierValue by using a fixed value... Now its working 👍🏻 image