Library not saving? (Block question)

Permalink
I made a block with a few fields, but for some reason the image field (which draws from the library) isn't saving, so when I go to edit, the image I'd originally chosen doesn't show up. Any idea how to fix this? Here are the files, not sure if posting everything is necessary in this case but I didn't want to leave anything out:

add.php:

<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
//$replaceOnUnload = 1;
?>
<?php
$al = Loader::helper('concrete/asset_library');
echo $al->file('ccm-b-file', 'tID', t('Choose File'), $bf)
?>
<?php $bf = File::getByID($tID);?>
<?php   
$includeAssetLibrary = true;
$assetLibraryPassThru = array(
   'type' => 'image'
);
$al = Loader::helper('concrete/asset_library');


controller.php:

<?php 
   defined('C5_EXECUTE') or die(_("Access Denied."));
   class RelLinkBlockController extends BlockController {
      var $pobj;
      protected $btTable = 'btRelLinkLocal';
      protected $btInterfaceWidth = "600";
      protected $btInterfaceHeight = "465";
      public function getBlockTypeDescription() {
         return t("Image and Text.");
      }
      public function getBlockTypeName() {
         return t("RelLink");
      }
      function getRelLink() {
         $content = $this->translateFrom($this->content);


db.xml:

<?xml version="1.0"?>
<schema version="0.3">
   <table name="btRelLinkLocal">
      <field name="bID" type="I">
         <key />
         <unsigned />
      </field>
      <field name="tID" type="I">
            <unsigned />
         <default value="0" />
        </field>
      <field name="fID" type="I">
            <unsigned />
         <default value="0" />
        </field>


edit.php, where the problem surely is:

<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
//$replaceOnUnload = 1;
?>
<?php 
$al = Loader::helper('concrete/asset_library');
echo $al->file('ccm-b-file', 'tID', t('Choose File'), $bf);
?>
<?php $file = File::getByID($tID); 
$filePath = $file->getVersion()->getRelativePath();?>
<?php  
$includeAssetLibrary = true; 
$assetLibraryPassThru = array(
   'type' => 'image'
);


view.php, editor_config.php, and editor_init.php probably aren't necessary to post, but if I'm wrong let me know and I'll post them asap.

Am I doing something horribly wrong (new to PHP, quite possible) or is this a simple fix? Thanks for any help.

stephmars
 
Remo replied on at Permalink Best Answer Reply
Remo
in edit.php $bf doesn't have any value. I can't see the code where you fetch any value..

You might want to check this block, it's a bit simpler but should give you enough hints about files in a block

http://www.codeblog.ch/2009/06/concrete5-staff-table/...
stephmars replied on at Permalink Reply
stephmars
Thank you, Remo!

I've installed the block and am using it as a reference. Funny, I've been to codeblog.ch many times (your site, right?), but didn't see this block, or maybe I skimmed over it... Anyway, hope I can put the pieces together. From a novice programmer, thank you sincerely for offering your help!

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.