https://gist.github.com/anonymous/5066277

The above could be very helpful. Here's the description: "By default, Commerce Auction (http://drupal.org/project/commerce_auction) puts the bid form on a separate page/tab from the auction node. The code below can be added to your theme's template.php file, and updated [minimally] to work with your site."

Comments

swim’s picture

Hey Josh,

I was in a similar situation where I needed to leverage the Commerce Auction bidding form for different blocks, some used ajax some didn't it was a mix bag.

I ended up copying the form & altering as such.

/**
 * Copy of Commerce Auction bidding form.
 */
function MODULE_auction_place_bid_form($form, &$form_state, $node) {
  // Include submission functions, these don't need duplication.
  module_load_include('inc', 'commerce_auction', 'includes/commerce_auction.pages');

  // Attach obvious form submit & validation handlers, just in case.
  $form['#validate'][] = 'commerce_auction_place_bid_form_validate';
  $form['#submit'][] = 'commerce_auction_place_bid_form_submit';

  $form['warnings'] = array(
    '#weight' => -1,
    '#type' => 'markup',
    '#markup' => '<p>' . t('Please keep in mind that once you bid on an auction, you are supposed to buy the product if you win the auction.') . '<br />' . t('We will decrease your rate and access in this website, or if it happens repeatedly, completely suspend your account.') . '</p>',
  );

  if (user_access('place bids')) {
    $entity = entity_create('commerce_auction_bid', array());
    $entity->type = 'auction_bid';
    field_attach_form('commerce_auction_bid', $entity, $form, $form_state);

    $form_state['#entity'] = $entity;
    $form_state['#node'] = $node;
    $form['save_bid'] = array(
      '#value' => t('Enter bid'),
      '#attributes' => array('class' => array('display-block', 'margin-top-10')),
      '#type' => 'submit',
      '#weight' => 100,
    );

    $currency = commerce_currency_load(commerce_default_currency());
    $form['bid_amount'][LANGUAGE_NONE][0]['amount']['#field_suffix'] = $currency['symbol'];
  }
  else {
    $form['register'] = array(
      '#type' => 'markup',
      '#markup' => l(t('Please Register to Bid'), 'user/register', array('attributes' => array('class' => array('button')))),
    );
  }

  if (isset($form['#metatags'])) {
    unset($form['#metatags']);
  }

  return $form;
}

For some reason trying to get the original bidding form via drupal_get_form returned an error; form id could not be found etc.

Cheers,