Mjoin does not work using datatable field instead of checkbox
Mjoin does not work using datatable field instead of checkbox
editor field with checkbox: (it works)
{
label: "Mansioni",
name: "mansioni[].man_id",
type: "checkbox"
}
editor field with datatable: (does not work)
{
label: "Mansioni",
name: "mansioni[].man_id",
type: "datatable"
}
$editor->join(
Mjoin::inst( 'mansioni' )
->link( 'dipendenti.dip_id', 'dipmans.dip_id' )
->link( 'mansioni.man_id', 'dipmans.man_id' )
->order( 'man_descr asc' )
->fields(
Field::inst( 'man_id' )
->validator( Validate::required() )
->options( Options::inst()
->table( 'mansioni' )
->value( 'man_id' )
->label( ['man_descr', 'man_cod'] )
->render( function ( $row ) {
return $row['man_descr'].' ('.$row['man_cod'].')';
} )
),
Field::inst( 'man_descr' ),
Field::inst( 'man_cod' )
)
);
table dipendenti
dip_id (AUTO INCREMENT)
dip_name = "NAME SURNAME"
table mansioni
man_id (AUTO INCREMENT)
man_cod = "ADML"
man_descr = "addetto al mulino"
table dipmans
dip_id (from table dipendenti)
man_id (from table mansioni)
foreign keys table dipmans
ADD CONSTRAINT `fk1` FOREIGN KEY (`dip_id`) REFERENCES `dipendenti` (`dip_id`)
ON DELETE CASCADE ON UPDATE RESTRICT;
ADD CONSTRAINT `fk2` FOREIGN KEY (`man_id`) REFERENCES `mansioni` (`man_id`)
ON DELETE CASCADE ON UPDATE RESTRICT;
Any advice? thanks,
Giuseppe
Answers
It should do, as shown in this example.
Can you give me a link to your page so I can take a look and see what is going wrong please?
Thanks,
Allan
Works perfectly in the following case:
The only difference is that I use the tip_sigla field instead of tip_id (as if I used man_cod instead of man_id in the previous case).
I use man_id because I would like the relationships between the tables not to change even if I were to change the value of man_cod.
Giuseppe
Hi Giuseppe,
Can you give me a link to a page showing the issue please?
Thanks,
Allan