Hi, i have the same behavior in my web app and i use a code before render field on my list view "periode" as say Klas:
I've two content :
- periode (in english period)
- stage (in english traineship)
In the content stage i have a field stage_periode (int, id of the periode), so the two content are link by this field.
If
a stage is store in a periode content my users can't delete the
periode. I alert by ('You can't delete periode because they are XX
stages stored'):
I share my code:
/** Nombre de stages (BeforeRender of list periode)*/
$db1 = JFactory::getDbo();
$query = $db1->getQuery(true);
$query->select($db1->quoteName(array('stage_periode')));
$query->from($db1->quoteName('l1_cck_store_form_stage'));
$query->where($db1->quoteName('stage_periode')." LIKE ".$fields['art_id']->value);
$db1->setQuery($query);
$stages = $db1->loadRowList();
$nb_stages =strval( count($stages));
$supr_alert="'Vous ne pouvez pas supprimer cette période. Il y a ".$nb_stages." stages enregistrés sur cette période'";
if(count($stages)!=0){
$fields['icon_trash']->typo='<a href="javascript: void(0);"
onclick="alert('.$supr_alert.');"><i></i></a>';
}else{
//Do nothing (link delete seblod)
}
/***********************************************/
icon_trash
is a field on the list "periode" who have the link DELETE (button 2
seblod). So if they are 0 stage i don't override the field icon-trash
Voilà