function commerce_backoffice_product_quick_edit_form in Commerce Backoffice 7
Form callback: Returns the form for modifying the product price and status.
1 string reference to 'commerce_backoffice_product_quick_edit_form'
- commerce_backoffice_product_handler_field_product_quick_edit_form::render in includes/
views/ handlers/ commerce_backoffice_product_handler_field_product_quick_edit_form.inc - Render the field.
File
- ./
commerce_backoffice_product.module, line 323
Code
function commerce_backoffice_product_quick_edit_form($form, &$form_state, $product) {
$form_state['product'] = $product;
$price_array = $product->commerce_price[LANGUAGE_NONE][0];
$currency = commerce_currency_load($price_array['currency_code']);
$amount = commerce_currency_amount_to_decimal($price_array['amount'], $price_array['currency_code']);
$price = number_format(commerce_currency_round(abs($amount), $currency), $currency['decimals'], $currency['decimal_separator'], $currency['thousands_separator']);
$update_permission = commerce_product_access('update', $product);
$disabled = !$update_permission;
$wrapper = drupal_html_id('commerce-backoffice-product-quick-edit-form');
$form['#prefix'] = '<div class="container-inline" id="' . $wrapper . '">';
$form['#suffix'] = '</div>';
$form['price'] = array(
'#type' => 'textfield',
'#title' => t('Price'),
'#title_display' => 'invisible',
'#default_value' => $price,
'#size' => 5,
'#disabled' => $disabled,
);
$form['status'] = array(
'#type' => 'select',
'#title' => t('Status'),
'#title_display' => 'invisible',
'#options' => array(
0 => t('Disabled'),
1 => t('Active'),
),
'#default_value' => $product->status,
'#disabled' => $disabled,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#ajax' => array(
'callback' => 'commerce_backoffice_product_quick_edit_form_ajax',
'wrapper' => $wrapper,
),
'#disabled' => $disabled,
);
if (!empty($form_state['product_saved'])) {
$form['save']['#suffix'] = t('Saved');
}
return $form;
}