Objective:
To combine AJAX Autocomplete with my Tableselect Form to create a key for users to select imported products that don't match existing products within your Drupal site. This new billing module would make it possible to use a specific 3rd party billing service.
Issue:
I am unable to get the following code to return the values inserted via the AJAX row. The array continues to send back the array keys of the row as both keys and values.
Here is what the original selection is:
And here is the returned values:
As you can see the rows selected have their array key listed as the value on return, where as the non selected row has the value 0.
Question: How do you change the return value so that it is the value that was selected on my AJAX form field?
function Test_product_form($form, &$form_state)
{
$form_state['page_num'] = 2;
$form['Markup'] = array(
'#markup' => t('Please select and synchronize Test Subscription Offers with your Drupal Commerce Product SKUS below:') . '</br>' . '</br>'
);
foreach ($form_state['sub_offers'] as $key => $offer) {
if ($offer['Status'] == 'Active') {
$product = commerce_product_load_by_sku($offer['OfferCode']) ? commerce_product_load_by_sku($offer['OfferCode']) : FALSE;
if ($product === FALSE) {
$rows[] = array(
'Test Subscription Offers' => array(
'data' => $offer['OfferCode'],
'id' => 'row' . $key . '-aso',
'class' => 'col-aso'
),
'Drupal Product SKUS' => array(
'data' => array(
// drupal_get_form('commerce_product_line_item_add_form'),
'#type' => 'textfield',
'#title' => t('Product SKU'),
'#description' => t('Enter the SKU of the product to add to the order.'),
'#autocomplete_path' => 'commerce_product/autocomplete/commerce_product/line_item_product_selector/product',
'#size' => 60,
'#maxlength' => 255,
//In order for AJAX within the Rows of tableselect form you must declare the
'#id' => $key . 'product_textfield'
),
'id' => 'row' . $key . '-dps',
'class' => 'col-dps'
)
);
} else {
$rows[] = array(
'Test Subscription Offers' => array(
'data' => $offer['OfferCode'],
'id' => 'row' . $key . '-aso',
'class' => 'col-aso'
),
'Drupal Product SKUS' => array(
'data' => array(
'#type' => 'link',
'#title' => $product->sku,
'#href' => 'admin/commerce/products/' . $product->product_id
// '#options' => $l_options,
// '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
),
'id' => 'row' . $key . '-dps',
'class' => 'col-dps'
)
);
}
}
}
$hinput = array(
'Test Subscription Offers' => 'aso',
'Drupal Product SKUS' => 'dps'
);
foreach ($hinput as $hkey => $hvalue) {
$header[$hkey] = array(
'data' => $hkey,
'id' => 'head-' . $hvalue,
'class' => 'col-' . $hvalue
);
}
$options = array();
foreach ($rows as $key => $row) {
$options[$key] = array(
'Test Subscription Offers' => $row['Test Subscription Offers'],
'Drupal Product SKUS' => $row['Drupal Product SKUS']
);
}
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
//'#js_select' => TRUE,
'#multiple' => TRUE
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#submit' => array(
'Test_payment_submit_step_two'
),
'#validate' => array(
'Test_payment_validate_step_two'
)
);
ddl_once($form);
return ($form);
}