- Code: Select all
function relational_table_field1__validate(&$record, $value, &$params){
$parent_record = df_get_record('parent_table_name', array('parent_table_primary_id' => $record->val('parent_table_primary_id')));
if (!$parent_record->val('sth')) return false;
//do something
return true;
}
I'm thinking if we could have a constructor with the &$record as parameter so we can just call df_get_record() once and the member's value can be used by all methods:
- Code: Select all
class tables_relational_tablename {
var $parent_table_primary_id;
var $parent_table_sth;
tables_relational_tablename(&$record){
$parent_record = df_get_record('parent_table_name', array('parent_table_primary_id' => $record->val('parent_table_primary_id')));
$this->parent_table_primary_id = $parent_record->val('id');
$this->parent_table_sth = $parent_record->('sth');
}
}
So the above validate function would look like this:
- Code: Select all
function relational_table_field1__validate(&$record, $value, &$params){
if (!$this->parent_table_sth) return false;
//do something
return true;
}
Can somebody know how we can do that?