[ic] Image Widget Revisited - Possible Fix

Cameron B. Prince cplists at princeservices.com
Sat Feb 10 16:00:13 EST 2007


Well I think I've found a fix for the Image Widget problem.

On or around line 2061 in Data.pm you'll see this:

                        unless (length($dref->[0])) {
                                # no need for a file update
                                if($file_oldfiles[$i]) {
                                        $dref->[0] = $file_oldfiles[$i];
                                }
                                else {
                                        $skip_for_now{$nm} = 1;
                                }
                                next;
                        }

If the "$skip_for_now{$nm} = 1" statement is commented out, a null selection
in the widget causes the existing data in the field to be removed as
desired. Now I'm sure that statement is there for a reason but I don't know
what that might be. My idea was to update it something like this:

$skip_for_now{$nm} = 1 unless get_widget_type($nm) eq 'imagehelper';

That seems like a hack though and there doesn't appear to be a facility to
get the widget type anyway.

What do you guys think the proper way to solve this would be?

Thanks,
Cameron

----------------------------------------------------------------------------

Hey guys,

I was able to replicate this problem on the demo site and I wanted to
provide the steps:

1) Login to the admin, choose tables, then products and select an item
2) Select the Images tab and click the meta link for the image field
3) On the Typical tab, add the Combo box filter
4) On the Advanced tab, change images/items to images/items/*
5) Click Ok to return to the table
6) Select an item and click the Images tab
7) Change the select box to (none) for the image field and click Ok

When you reedit the item, you'll see that the original image still persists.

I will try to track this down and fix it. I wish I had a better idea of what
mv_data_file_oldfile is because it's not clear to me if this is a problem
with the widget not passing the correct data or problems handling the data
in Data.pm.

Any ideas?

Thanks,
Cameron

----------------------------------------------------------------------------

I am back to work on the imagehelper widget and I've ran into a new problem.
When none is selected it doesn't cause the value in the field to be cleared.
When you reedit the record you see that the original image is still
selected. Selecting none does work properly with the imagedir widget.

I compared the output of each widget in the table editor and came up with
this:


IMAGEHELPER:

<td class="cwidget" style="vertical-align: top">
<A HREF="images/items/140.jpg">140.jpg</A>
<INPUT TYPE=hidden NAME=mv_data_file_field VALUE="image">
<INPUT TYPE=hidden NAME=mv_data_file_name_from VALUE="">
<INPUT TYPE=hidden NAME=mv_data_file_path VALUE="images/items">
<select name="mv_data_file_oldfile">
<option value="">(none)
<option value="100.jpg">100.jpg
...
</select>
<INPUT TYPE=file NAME="image" VALUE="140.jpg">
<input type="hidden" name="ui_filter:image" value="nullselect">
</td>


IMAGEDIR:

<td class="cwidget" style="vertical-align: top">
<input type="text" name="image" size="" value="">
<select name="image" class="s3">
<option value="">None
<option value="100.jpg">100.jpg
...
</select>
<input type="hidden" name="ui_filter:image" value="nullselect">
</td>


Do you think this is a widget issue or a problem in Data.pm?

Thanks,
Cameron



More information about the interchange-users mailing list