Can not publish page directly

Permalink
I create a page with composer and add content and an image (I show that image also in pagelist). Everything works great. But when I edit the page and create an extra block I cannot directly publish the page. It tells me "the field productafbeelding is required" but the images already exists.

So then my only option is to save changes. Then I get the blue box "Page is waiting for approval.." with the button "Approve version". When I click that the page gets approved.

Any Idea what goes wrong. Or how to fix this?

1 Attachment

 
Kurtopsy replied on at Permalink Reply
Kurtopsy
I haven't experienced this, but this may help.
<?php
         if ($attributeName) {  
         $thumb = $ih->getThumbnail($attributeName, 100, 999, false); 
         ?>
        <img src="<?php  echo $thumb->src ?>" width="<?php  echo $thumb->width ?>" height="<?php  echo $thumb->height ?>" alt="" />
        <?php } else { ?>
        <img src="http://someaddress.com/image.png" width="<?php  echo $thumb->width ?>" height="<?php  echo $thumb->height ?>" alt="" />
        <?php } ?>

This just checks if the attribute is empty, and if it is - put image.png as the value. Image.png would hypothetically be a 1px x 1px transparent png.
studio4graphics replied on at Permalink Reply
Thank you for your reply. But in this case the thumbnail is not empty (because I uploaded it myself) but I still get the error when trying to edit (not with composer but in the page itself) and publish the page again.

So I like to know how I get the error. Is there something wrong with my code?
If not how can I combine your code with mine? (where to put the else?)

I use the following code:
<?php if (is_object($thumbnail)): ?>
    <img src="<?php  echo ($thumbnail->getVersion()->getThumbnailURL('product')); ?>"/>
<?php endif; ?>
studio4graphics replied on at Permalink Reply
Anyone else getting this problem? Getting this in all my projects using composer in combination with an image. Very annoying!
hutman replied on at Permalink Reply
hutman
Do you have a controller for this page type which checks required fields? If so can you show us the code?
studio4graphics replied on at Permalink Reply
My steps:
1) Create image attribute (thumbnail) (dashboard/pages/attributes)
2) Add Image to page form (dashboard/pages/types/form)
* and select that the image is required in form image option)
3) Call for image attribute in template and load different thumbnail preset sizes)

<?php defined('C5_EXECUTE') or die("Access Denied.");?>
<?php $this->inc('elements/header.php'); ?>
<header class="headerwrapper"> 
    <div class="container-fluid">
        <div class="row">
            <?php  $this->inc('elements/nav.php'); ?>  
        </div>
    </div>
</header>
<div class="headerimagevvp headerimgproject">
    <?php $a= new Area ('headerimage'); $a->display($c); ?>
    <?php
        $img = $c->getAttribute('thumbnail'); ?>
        <?php if ($img): ?>
        <img class="blurimg" src="<?php  echo ($img->getVersion()->getThumbnailURL('mainheader')) ?>"/>


4) Add page (with composer) and insert image an data (works ok)
5) Add extra element outside composer to the page just created (I get an alert that the field "Afbeelding" is required)
6) For now is just save, and then I get the blue box in right corner thats say's to approve the page. That works.