Fixed 'Bug' in RemoveRelatedRecordForm.php

A place to discuss development of the Xataface core.

Postby graeme1950 » Thu Oct 05, 2006 3:30 am

Sorry if I post this in the wrong forum or place but didn't know what else to do.

Problem:

Selected recordset checkboxes ~ if none selected and 'Remove Selected Records' is clicked you get a 'for each error on line 181'

Solution:

To stop this I put in an if statement on the function display() on thre RemoveRelatedRecordForm.php
as follows

function display(){
if ( $this->_toBeRemoved !='' ){ // Added to stop 'for each error on empty result
$this->_build();
$domainTable = $this->_relationship->getDomainTable();
if ( PEAR::isError($domainTable) ){
$domainTable = $this->_relationship->_schema['selected_tables'][0];
}
$domainTable = Dataface_Table::loadTable($domainTable);
$io =& new Dataface_IO($domainTable->tablename);



echo "

Are you sure you want to remove the following records from the relationship '".$this->_relationshipName."'?

";
echo "
    ";
    //print_r($this->_toBeRemoved);
    foreach ($this->_toBeRemoved as $remKeys){
    $keyvals = explode('-', $remKeys);
    $query = array();

    foreach (array_keys($domainTable->keys()) as $keyname){
    $query[$keyname] = array_shift($keyvals);
    }
    $record = new Dataface_Record($domainTable->tablename, array());
    //print_r($query);

    $io->read($query, $record);
    echo "
  • ".$record->getTitle()."
  • \n";
    unset($record);

    }
    echo "
";

// Added to stop 'for each error on empty result
} else {

echo "

No records selected from the relationship '".$this->_relationshipName."'?

";
}

parent::display();
}

I hope this helps and if some one could tell me where to go (politely!) I'll go.
Best Regards
Graeme Hird
graeme1950
 
Posts: 14
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Oct 05, 2006 8:31 am

Thanks for posting this fix, Graeme. I'll add it to the Dataface source to be available in the next version.

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby graeme1950 » Fri Oct 06, 2006 6:54 am

You're welcome and thank you for an excellent product, it's definately making my life easier for creating user data interfaces to my systems.
Best Regards
Graeme
graeme1950
 
Posts: 14
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Developers

Who is online

Users browsing this forum: No registered users and 5 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved