A place for users and developers of the Xataface to discuss and receive support.
by tnorbut13 » Tue Aug 11, 2009 12:08 pm
I'm getting the following error message with a delegate class I have put in. Please help.
Fatal error: Class 'tables_PartVendorPricing' not found in /var/www/xataface/Dataface/Table.php on line 1049
Delegate Class:
<php>valueChanged('Vendor_ID') ){
$vendorid = df_get_record('Vendor', array('Vendor_ID'=>'='.$record->val('Vendor_ID')));
$record->setValue('PartVendorPricing', $vendorid->val('PartVendorPricing'));
}
}
?>
Conf.ini:
; File: conf.ini
; Description:
; ------------
; This file contains configuration information for the dataface framework.
; Configuration options include such things as database connection information
; tables to be displayed in the menu, and behavioral and display characteristics
; of the dataface application (like whether to display the menu).
;
;debug=1
default_table=RFQ
[_database]
host = "localhost"
user = "xxxx"
password = "xxxx"
name = "xxxx"
[_auth]
users_table = Users
username_column = Username
password_column = Password
[_tables]
dashboard = "Dashboard"
Customer = "Customer"
Sales = "Sales"
RFQ = "RFQ"
Purchasing = "Purchasing"
Pricing = "Pricing"
Part = "Part"
Vendor = "Vendor"
PartVendorPricing = "PartPricing"
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Tue Aug 11, 2009 12:39 pm
I think your PHP code is being messed up by PHPBB. Check the "Disable HTML in this post" checkbox and post again.
In any case your problem is that your delegate class is named incorrectly (probably has a typo). Your delegate class should contain a class named:
tables_[tablename] where [tablename] is the name of your table.
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Tue Aug 11, 2009 12:41 pm
Delegate Class:
<?php
function beforeSave(&$record){
if ( $record->valueChanged('Vendor_ID') ){
$vendorid = df_get_record('Vendor', array('Vendor_ID'=>'='.$record->val('Vendor_ID')));
$record->setValue('PartVendorPricing', $vendorid->val('PartVendorPricing'));
}
}
?>
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Tue Aug 11, 2009 12:46 pm
OK.. You need to place this method inside a class as follows:
- Code: Select all
<?php class tables_PartVendorPricing { function beforeSave(&$record){ if ( $record->valueChanged('Vendor_ID') ){ $vendorid = df_get_record('Vendor', array('Vendor_ID'=>'='.$record->val('Vendor_ID')) ); $record->setValue('PartVendorPricing', $vendorid->val('PartVendorPricing')); } }
}
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Tue Aug 11, 2009 12:51 pm
Ok. Getting closer.
Now I get
Fatal error: Call to a member function val() on a non-object in /var/www/rfqtest/tables/PartVendorPricing/PartVendorPricing.php on line 6
Does this mean that it can't find the field value that it needs?
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Tue Aug 11, 2009 12:59 pm
It looks like the call to df_get_record() didn't actually find any matching records. So when you tried to use the found record, it was just null:
i.e. $venderid is null - there was no record found in the Vendor table such that the Vendor_ID was $record->val('Vendor_ID')
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Tue Aug 11, 2009 1:00 pm
Ok. But there are records in the Vendor table. Isn't that what I'm doing here? I'm trying to pull the Vendor ID from the Vendor table and insert it in the PartVendorPricing Vendor ID when I save.
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Tue Aug 11, 2009 1:43 pm
You need to do a little debugging.
What I can tell you is that there are no records in the Vendors table matching your query. Good debugging technique might be:
print_r($record->vals());
exit;
To see what is in the record. Perhaps the Vendor_ID field doesn't contain what you think it does.
-Steve
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Thu Aug 13, 2009 12:21 pm
Ok. Debugging showed that it was trying to put the name in the field instead of the id. However, I still can't get this to work. Have tried removing the delegate class entirely and just having the ability to put 'Vendor_ID = x' manually to test. Still will not store the vendor id in the join table.
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Thu Aug 13, 2009 12:33 pm
Can you describe your steps when you are trying to insert the record? Are you doing this via add related record, or via new record?
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Thu Aug 13, 2009 12:38 pm
Trying to add a new record. What I need to happen is this:
I start an RFQ. Select parts to go with RFQ. Select vendors that go with each part. Vendors supply back pricing information.
I can do all of the above except the vendor association. Don't know if it's a table structure issue or my own personal mental retardation...
Anyway, on the add new record I've been able to get the Vendor field to display the Name instead of the ID via code you've left for me before:
http://xataface.com/forum/viewtopic.php?p=23562#23562
Now I just need the insert of the Vendor ID into the join table to get this working.
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by tnorbut13 » Fri Aug 14, 2009 8:38 am
Any thoughts on this.
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by shannah » Fri Aug 14, 2009 10:20 am
I start an RFQ. Select parts to go with RFQ. Select vendors that go with each part. Vendors supply back pricing information.
Please translate this into something like:
1. I go to the RFQ table.
2. Click "New Record"
3. In the X field (using the Y widget) I check Z parts (which come from a valuelist ...)
4. etc...
I'm trying to get a clear picture of why this is happening, and it's still a little vague (the process) to me.
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by tnorbut13 » Fri Aug 14, 2009 11:44 am
1 Start new RFQ record on the RFQ table by clicking new record
2 Input information for RFQ regarding due dates. Click Save (this all works so I won't elaborate)
3 'Current Record: Untitled RFQ Record' comes up with the related tables for RFQ. I select the 'Part' table.
4 On Part table, select 'add new part record'
5 On the Part Number field, using the yui_autocomplete widget, I input the part number which come from a value list (__sql__ = "Select XXXX_Part_Number from XXXX_Part_Info"). Input quantities requested into the quantities fields. (see image http://www.lutzsales.com/images/rfq/parttable.jpg) Click Save
6 At this point, the program returns to the RFQ related tab for part (see image (see image http:///www.lutzsales.com/images/rfq/parttable2.jpg)
I click the 'Part Request Number' to go to the Part Request table.
7 On the Part Request Table, I select the VendorPricing tab (connected to the PartVendorPricing table). I select add New VendorPricing record.
8 I Choose a Vendor from the Vendor ID field (using a Select Widget) that is populated with vendor Name from a valuelist and a delegate file. I click save. (see image http://www.lutzsales.com/images/rfq/vendorselect.jpg) Also see code for field, valuelist and delegate in next post.
9 Application goes back to PartVendorPricing table without any Vendor_ID input. (see image at http://www.lutzsales.com/images/rfq/vendorresult.jpg). The application is trying to pass the Vendor name into the Vendor ID field, which won't work. I don't want to add the Vendor name in as another field on the PartVendorPricing join table either as this is a normalized environment.
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
by tnorbut13 » Fri Aug 14, 2009 11:47 am
Code for PartVendorPricing table widgets, etc.
Fields:
[Vendor_ID]
widget:type = select
vocabulary = Vendors
Valuelists:
[Vendors]
__sql__ = "select Vendor_ID, Vendor_Name from Vendor ORDER BY Vendor_Name"
PartVendorPricing Delegate class:
<?php
class tables_PartVendorPricing {
//function beforeSave(&$record){
// if ( $record->valueChanged('Vendor_ID') ){
// $vendorid = df_get_record('Vendor', array('Vendor_ID'=>'='.$record->val('Vendor_ID')));
// $record->setValue('PartVendorPricing', $vendorid->val('PartVendorPricing'));
// }
// }
function Vendor_ID__pushValue(&$record, &$element){
// Get the employer name as entered in the text field
$vendorName = $element->getValue();
// Get the associated employer id
$vendorRecord = df_get_record('Vendor', array('Vendor_Name'=>$vendorName));
// If employer doesn't exist yet, we create a new one
if ( !$vendorRecord){
$vendorRecord = new Dataface_Record('Vendor', array());
$vendorRecord->setValue('Vendor_Name', $employerName);
$vendorRecord->save();
}
// Return the employer ID for this employer
return $vendorRecord->val('Vendor_ID');
}
function Vendor_ID__pullValue(&$record, &$element){
// we'll be a bit tricky here and use valuelists on this
// field. When using valuelists, the display() method will
// display the display value of the field instead of the
// id. Since we want to return the display value,
// all we need to do is...
return $record->display('Vendor_ID');
}
}
?>
-
tnorbut13
-
- Posts: 36
- Joined: Thu Apr 23, 2009 7:46 am
- Location: Chicago, IL
Return to Xataface Users
Who is online
Users browsing this forum: No registered users and 37 guests
|