Jump to content

Custom ImageExtra fields not saving


AAD Web Team
 Share

Recommended Posts

G'day … I'm not sure if this is an actual problem, or just my lack of understanding about how this is supposed to work. We're using PW 3.0.131 with the ImageExtra 1.0.6 module. I'm using the API to automatically import lots of pages with images into PW from a different web CMS.

I'm having trouble updating some of the custom image fields, which don't save unless a core image field is also updated.

In code, where $p is a particular page and $img is a particular image on that page, this works:

$p->of(false);
$img->description = 'foo'; // Standard field
$img->photographer = 'bar'; // Our custom field created with ImageExtra
$p->save(); // Updates the record in the database.

But this doesn't work:

$p->of(false);
$img->photographer = 'bar'; // Our custom field created with ImageExtra
$p->save(); // Makes no difference to the record in the database.

This also doesn't work:

$p->of(false);
$img->photographer = 'bar'; // Our custom field created with ImageExtra
$p->save('photographer'); // Makes no difference to the record in the database.

In all cases the $p->save method returns true to indicate success.

Can anyone help me understand what's going on here? Thanks!

Link to comment
Share on other sites

This sounds like it relates to change tracking, with changes to the custom fields not being detected. Did you see the API example in the module readme, where track changes is specifically set for the custom field being set?

Quote

Setting the values

From the API side you can set the values like this:


$page->setOutputFormatting(false);
$page->images->trackChange('title');
$image = $page->images->getRandom(); // or whatever image you want
$image->title = 'Title in default language';
$image->title($languages->get('fi'), 'Title in Finish');
$image->title($languages->get('de'), 'Title in German');
$page->save();
$page->setOutputFormatting(true);

Having said that, when I tested I wasn't able to save changes to ImageExtra custom fields via the API regardless of the trackChange() call or if the description was also set.

This question probably belongs in the ImageExtra support topic so the module author might see it, although they haven't been active here lately so not sure how well the module is being supported currently.

Link to comment
Share on other sites

  • 1 year later...

It´s a old post, but i'm looking for this same problems. Hope, helps you, too.

  1. It must be noted that if "When output formatting is off the value of an image/files field is always a WireArray" found here
  2. to save works only $page->save(image/files field)

Example for a custom field "counter" :

$page->of(false);
$file = $page->csvFiles->first();
$file->counter = "your content here";
$page->save('csvFiles');

Actually easy.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...