is mJoin only reading
is mJoin only reading
I once used the join classes in php to read and write from a link table. Now when i upgrade and use the mJoin i only seem to be able to read.
Here is my code:
$data->join(
Mjoin::inst( 'contacts' )
->link( 'cases.caseID', 'caseClient.caseID' )
->link( 'contacts.contactID', 'caseClient.contactID' )
->fields(
Field::inst( 'contactID' )
->options( function () use ( $db ) {
$userList = $db->sql( "SELECT concat(contactLastName,', ',contactFirstName,' ',contactMiddleName) as name, contactID as id FROM contacts WHERE contactType != 'Company' order by contactLastName asc, contactFirstName asc" );
$out = array(array('label'=>'Select...','value'=>''));
while ( $row = $userList->fetch() ) {
$out[] = array(
"label" => $row['name'],
"value" => $row['id']
);
}
return $out;
} ),
Field::inst( 'contactID' )->validator( 'Validate::notEmpty' )
)
)
I am getting the data from the contacts table but when I insert and update no values are written to caseClient. what am I doing wrong.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
That looks like it should work. Could you link to the page showing the issue please.
Allan
This is on a local server but maybe the full server code will help:
I'd need the Javascript and also an example of the data loaded from the get and edit requests. Also the data submitted on edit.
If you are able to publish it on a public server that would make it much easier to debug.
Thanks,
Allan