Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$content->setFieldValue('image', 'image.png'); doesn't work #3481

Open
Saltibarsciai opened this issue Sep 16, 2023 · 2 comments
Open

$content->setFieldValue('image', 'image.png'); doesn't work #3481

Saltibarsciai opened this issue Sep 16, 2023 · 2 comments

Comments

@Saltibarsciai
Copy link

Saltibarsciai commented Sep 16, 2023

Can't update/create image field in fixtures

    protected function load(ContentFactory $factory): void
    {
        $content = $this->factory->create('image');

        $content->setFieldValue('slug', 'icon');
        $content->setFieldValue('image', 'image.png');

        $this->factory->save($content);
    }

Details

Question Answer
Relevant Bolt Version 5.1.20
Install type composer
PHP version 8
Web server Nginx
For UX/UI issues Browser name and version

Reproduction

  1. have a contentype
image:
    name: Images
    slug: image
    singular_name: Image
    searchable: false
    viewless: true
    fields:
        slug:
            type: slug
        image:
            type: image
  1. update/create record
        $content = $this->factory->create('image');

        $content->setFieldValue('slug', 'icon');
        $content->setFieldValue('image', 'image.png');

        $this->factory->save($content);

Bug summary

Problem is text fields are updated as expected, but not image field

Specifics

* Mention the URL where this bug occurs, if applicable
* What version of Bolt are you using (down to the very last digit!) 5.1.20
* What method did you use to install Bolt - composer
* What browser and version you are using - using cli

Expected result

Image gets updated

Actual result

text fields are updated, image field not

@bobdenotter
Copy link
Member

Why are you saving the factory? Shouldn't you save/persist the Content itself?

@Saltibarsciai
Copy link
Author

The same result is got when using

$this->factory->save($content);

or

$manager->persist($content);
$manager->flush();

Initially I used factory because bolt5 docs recommended it https://docs.boltcms.io/5.0/extensions/creating_content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants