0

                $draft = new Drafts();

                var_dump($entry->slug);

                $draftEntry = Entry::find()->slug($entry->slug)->one();

                $draftEntry->typeId = 32;

                $draftEntry->setFieldValue('heroTitle', "Test Title");

                $newDraft = $draft->createDraft($draftEntry, 142109,'New OTL Draft-Test-8', 'Edit this draft before saving as live entry', array() );

                $newMatrix = \craft\elements\MatrixBlock::find()
                    ->fieldId(425)
                    ->owner($newDraft)
                    ->all();

                $newMatrix['new1'] = array(
                    'type' => 'vidyardVideoPlayer',
                    'enabled' => true,
                    'fields' => array(
                        'vidyardId' => '1234567890'
                    )
                );

                $newDraft->setFieldValues(['onTheLineModules' => $newMatrix]);

                var_dump(Craft::$app->elements->saveElement($newDraft));

                echo json_encode($newDraft->getFieldValues(['onTheLineModules'], null), true);

                Craft::$app->elements->saveElement($newDraft);

                return $newDraft;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.