When I am tying to delete rows (means one or more rows were selected, in this particular case I had selected rows 2, 3 and 4), if I print the array $form_state['values']['category_boundary']['category_fieldset']['catg'] using dpm(), I get below output,
Thats the reason, thought of taking $index as key where $index can be one of 0,1,2,3.
Using the logic mentioned in my first email, I will be able to delete the rows 2, 3 and 4.
Since irrespective of fact, 0th row is selected or not, always value is 0. Thats the reason, why logic (if($form_state['values']['category_boundary']['category_fieldset']['catg'][$index] > 0) ) does not work.
Wow I can’t believe I didn’t catch that either. Good eye!
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Anthony
Sent: Thursday, September 13, 2012 10:01 AM
To: support@drupal.org
Subject: Re: [support] Tableselect in forms issue
Shouldn't it be greater equal zero to get the first element?
On Thu, Sep 13, 2012 at 8:13 AM, Metzler, David <metzlerd@evergreen.edu> wrote:
Seems like it should work provided you really meant $index to be $key. That’s not in your real code, right? If it is in your cod that way, that’s the bug.
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Kamal Palei
Sent: Thursday, September 13, 2012 5:32 AM
To: support@drupal.org
Subject: [support] Tableselect in forms issue
Hi All
I am trying to use tableselect in forms as per below code.
$form['category_boundary']['category_fieldset']['catg'] = array
(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#multiple' => TRUE,
'#js_select' => FALSE,
);By manipulating options array, I can add the rows in forms table.
Sometimes I need to remove the selected rows from form table.
My question is, how can I determine if a particular row is selected.
Currently using below code to determine which row is selected.
foreach($form_state['values']['category_boundary']['category_fieldset']['catg'] as $key => $value)
{
if($form_state['values']['category_boundary']['category_fieldset']['catg'][$index] > 0)
{
//row is selected.
}
else
{
//row is not selected.
}
}
I can determine all the rows if those are selected or not except the 0th row.
Can somebody tell me, what is the RIGHT way to determine if a particular row in a table is selected or not.
Best Regards
Kamal
--
[ Drupal support list | http://lists.drupal.org/ ]
--Anthony Stefan Maciejowski
--
[ Drupal support list | http://lists.drupal.org/ ]