This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

blubcow
blubcow

Hi, i don't understand it. I've created a "HasMany" Relation with Form Builder, just to test this case:
I have a Parent Model, "Project", which has many Children, "Work".

Project.php - has

public $hasMany = [
      'works' => 'Vendor\Plugin\Models\Work'
];

project/fields.yaml - has

tabs:
    fields:
        works:
            label: Works
            oc.commentPosition: ''
            nameFrom: name
            descriptionFrom: description
            span: left
            context:
                - create
                - update
            type: relation
            tab: 'Tab 1'

Now if we visit our "Projects" backend form, we see a list of "Works", but the value is missing.
I've tried getting $this->formField in my own relation plugin, but there is none. Even when other relation types with a similar setup are getting the value just fine.
What is going on?
Help is really appreciated!

Last updated

blubcow
blubcow

SOLVED - hasMany relation missing values

Oh, now that is really funny. The relation form widget can't get a value from an "hasMany" relation,
UNLESS - you update composer.
I've just removed the whole vendor/ folder and run composer install.
For the record, I've used the official installer, downloaded just now, when this error occured.

The composer.json file I've been running:

{
    "name": "october/october",
    "description": "October CMS",
    "homepage": "http://octobercms.com",
    "keywords": ["october", "cms", "octobercms", "laravel"],
    "license": "MIT",
    "authors": [
        {
            "name": "Alexey Bobkov",
            "email": "aleksey.bobkov@gmail.com",
            "role": "Co-founder"
        },
        {
            "name": "Samuel Georges",
            "email": "daftspunky@gmail.com",
            "role": "Co-founder"
        }
    ],
    "support": {
        "issues": "https://github.com/octobercms/october/issues",
        "forum": "http://octobercms.com/forum/",
        "docs": "http://octobercms.com/docs/",
        "irc": "irc://irc.freenode.net/october",
        "source": "https://github.com/octobercms/october"
    },
    "require": {
        "php": ">=5.5.9",
        "october/rain": "dev-stable",
        "october/system": "dev-stable",
        "october/backend": "dev-stable",
        "october/cms": "dev-stable",
        "laravel/framework": "5.1.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~4.0",
        "phpunit/phpunit-selenium": ">=1.2"
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php",
            "tests/UiTestCase.php",
            "tests/PluginTestCase.php"
        ]
    },
    "scripts": {
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
linusbostrom13155
linusbostrom13155

Is this still the case? I'm having the exact same issue, but without ever having used composer in any way. Do I still need to update composer?

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.