The identifier fID is missing for a query of Concrete\Core\File\File (5.7)

Permalink
In respinding tohttps://www.concrete5.org/community/forums/customizing_c5/my-custom-... I discovered a problem that I get but he does not, but other have as well (likehttp://www.concrete5.org/community/forums/5-7-discussion/error-when...

I have a new block, and when I add this new block I get

"The identifier fID is missing for a query of Concrete\Core\File\File"

This code is based on the above referenced link and the older posthttp://www.concrete5.org/community/forums/customizing_c5/building-a...

add.php
<?php
    defined('C5_EXECUTE') or die(_("Access Denied."));
    $al = Loader::helper('concrete/asset_library');
?>
<div class="ccm-ui">
    <div class="alert-message block-message info">
        <?php echo t("This form is used to add corporate level employees.") ?>
    </div>
    <?php
        echo $form->label('name', t('Name'));
        echo $form->text('name');
        echo $form->label('title', t('Title'));
        echo $form->text('title');
        echo $form->label('biography', t('Biography'));
        echo $form->text('biography');


the echo prints "[]"... so, $fID is does not exist, which seems reasonable as I do noit see it defined anywhere, yes, in boith examples that use this same syntax, $fID DOES exist, and is also not defined anywhere, so I assume it is magically passed

controller.php
<?php
namespace Application\Block\CorporateEmployee;
use Concrete\Core\Block\BlockController;
class Controller extends BlockController
{
    protected $btTable = "btCorporateEmployees";
    protected $btInterfaceWidth = "350";
    protected $btInterfaceHeight = "300";
    public function getBlockTypeName() {
        return t('Corporate Employees');
    }
    public function getBlockTypeDescription() {
        return t('This block is used to manage existing & new corporate employees.');
    } 
}



db.xml
<?xml version="1.0"?>
<schema version="0.3">
    <table name="btCorporateEmployees">
        <field name="bID" type="I">
            <key />
            <unsigned />
        </field>
        <field name="name" type="X2">
            <default value="" />
        </field>
        <field name="title" type="X2">
            <default value="" />
        </field>
        <field name="biography" type="X2">
            <default value="" />



edit.php
<?php
    defined('C5_EXECUTE') or die(_("Access Denied."));
    $al = Loader::helper('concrete/asset_library');
?>
<div class="ccm-ui">
    <div class="alert-message block-message info">
        <?php echo t("This form is used to edit corporate level employees.") ?>
    </div>
    <?php
        echo $form->label('name', t('Name'));
        echo $form->text('name', $name);
        echo $form->label('title', t('Title'));
        echo $form->text('title', $title);
        echo $form->label('biography', t('Biography'));
        echo $form->text('biography', $biography);



view.php
<?php defined('C5_EXECUTE') or die(_("Access Denied.")) ?>
<div class="row full-width">
    <div class="row">
        <?php echo($fID); ?>
        <div class="col-lg-7 col-lg-offset-1">
            <h3><span class="name"><?php echo($name); ?></span><span class="title"><?php echo($title); ?></span></h3>
            <hr class="little-orange">
            <p><?php echo($biography); ?></p>
        </div>
    </div>
</div>


Any ideas?

Thanks

ntisithoj
 
ntisithoj replied on at Permalink Best Answer Reply
ntisithoj
Found the answer...

the following code needed to be added to the top of add.php and edit.php

if ($fID > 0) {
        $bf = File::getByID($fID);
        if ($bf->isError()) {
            unset($bf);
        }
    }
micrdy replied on at Permalink Reply
micrdy
Great you found an answer to your problem. But when I add this to my code $fid is always null. So the getFileById is never called. What is fid?