In the admin section of a component, i have this form:
I just added the checkboxes in the left following this Joomla API.
MyCode:
$i=$rows_num;
$checked = JHTML::_( 'grid.id', $i, $voter["vid"] );
echo $checked;
And the Delete button shown in picture like that:
$bar->appendButton( 'Link', 'delete', 'Διαγραφή συγκεκριμένων ψήφων', 'index.php?option=com_exnetpolls&deleteit='.$isnotempty.'&gotcha=yo ');
The component isnt mine and the creator didnt use a controller ( every single action is executed in exnetpolls.php file ) so i created a new file getitdeleted.php and in exnetpolls.php i added this code :
exnetpolls.php (first file that getting executed)
if($_GET['deleteit']!="" && $_GET['deleteit']!=NULL){
include("getitdeleted.php");
}
And in getitdeleted.php
<?php
defined('_JEXEC') or die('Restricted access');
echo "test";
$cid = JRequest::getVar('cid',array(),'','array');
var_dump($cid);
if(isset($_GET['gotcha'])){
echo "worked".$_GET['deleteit'];
//code to delete from db
unset($_GET['gotcha']);
}
I know the way im using is a bit retarted,but it works except that the:
$cid = JRequest::getVar('cid',array(),'','array');
var_dump($cid);
returns array(0) {}
Altough if i type in my browser :
index.php?option=com_exnetpolls&deleteit=18&gotcha=yo&cid[]=2
the var_dump returns : array(1) { [0]=> string(1) "2" }
I also noticed that i could somehow parse the value with jquery using the id of input, but i would like to do that if it was my last option.
<input id="cb15" name="cid[]" value="2278" onclick="Joomla.isChecked(this.checked);" title="Πλαίσιο ελέγχου για τη σειρά 16" type="checkbox">
I tried also to pass the cid[] somehow with the delete button like so:
$bar->appendButton( 'Link', 'delete', 'Διαγραφή συγκεκριμένων ψήφων', 'index.php?option=com_exnetpolls&deleteit='.$isnotempty.'&gotcha=yo&cid[] ');
But it doesnt work.Could a joomla specialist enlight me please on what am i doing wrong here ?
EDIT: forgot to mention that i would like to check before pressing the DELETE button if cid[]==NULL
so i can change the value of $isnotempty
. when i var_dump the $cid = JRequest::getVar('cid',array(),'','array');
in the file that i create the input, i get again a null array.
<input id="cb0" name="cid[]" value="73" onclick="Joomla.isChecked(this.checked);" type="checkbox">
<input id="cb15" name="cid[]" value="2278" onclick="Joomla.isChecked(this.checked);" title="Πλαίσιο ελέγχου για τη σειρά 16" type="checkbox">
var_dump($_POST)-> array(0) { }
<form action="" name="adminForm">
and i use the delete button to do the work. Should i put METHOD="POST" to my form, and make the delete button a submit button that would do the same stuff??