Re: Problem with DBDOFB and fb_crossLinks
| From: | Justin Patrin | Date: | Tue, 21 Mar 2006 03:59:59 +0000 |
| Subject: | Re: Problem with DBDOFB and fb_crossLinks | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23359@lists.php.net to get a copy of this message | ||
On 3/20/06, Jose Manuel Zea <jmzeag@yahoo.es> wrote:
> Hi:
>
> I´m using PHP5 and the last version of DBDOFB, and I have the following
> tables:
>
> CREATE TABLE
collection (
> collection_id int(10) unsigned NOT NULL auto_increment,
> name varchar(30) NOT NULL default '',
> PRIMARY KEY (collection_id)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>
> CREATE TABLE collection2permission (
> collection_id int(10) unsigned NOT NULL default
> '0',
> permission_id int(10) unsigned NOT NULL default
> '0',
> PRIMARY KEY
> (collection_id,permission_id)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>
> CREATE TABLE permission (
> permission_id int(10) unsigned NOT NULL auto_increment,
> name varchar(30) NOT NULL default '',
> description varchar(100) default NULL,
> PRIMARY KEY (permission_id)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>
> Collection2permission, it´s the linking table.
>
> And for the Collection Form, I need a checkbox for every permission filled
> in the correspondent table.
>
> So, I defined the following in my collection.php file:
>
> var $fb_crossLinks = array(array('table' => 'Collection2permission',
> 'fromField' => 'collection_id',
> 'toField' => 'permission_id'));
>
> And, it´s working. But the problem is when I post the form, it dosen´t work
> properly, because whe I check or uncheck the items, it doesn´t create or
> delete the relationships in the linking table.
>
> One thing I discovered, trying to debug what is happening it´s that in the
> line number 2763 in the file FormBuilder.php, sanitizeFieldName returns the
> value '__crossLink_Collection_permission_collection_id_permission_id' and
> the field in $editableFields is
> "__crossLink_Collection2permission_collection_id_permission_id", the
> difference it´s a 2 in the middle of the word. So, the conditional if
> (in_array($crossLinkName, $editableFields)) it´s going to be always false.
>
> What I commented this line, trying to see if the problem was that I cannot
> name a table using a number, but it´s still not working.
>
> Can anyone help me, please? I don´t know what else to do.
>
> Thank you in advance.
>
Try using __crossLink_Collection_permission_collection_id_permission_id
in userEditableFields. Or use $fb->_sanitizeFieldNames() on your
crossLink name.
--
Justin Patrin