Definition

auction_bid_form($edit)
ecommerce-5--4/contrib/auction/auction.module, line 46

Description

Generates the HTML elements required for an auction bidding form. You can retheme this form by overriding theme_auction_bid_form().

Parameters

$edit Array, A replica of the current node for editing.

Code

<?php
function auction_bid_form($edit) {
  $product = node_load($edit['nid']);

  if (time() > $product->expires) {
    drupal_set_message(t('This auction has ended.'));
    drupal_goto("node/$product->nid");
  }

  $form['bid'] = array(
    '#type'          => 'textfield',
    '#default_value' => $edit['bid'],
    '#size'          => 10,
    '#maxlength'     => 50,
    '#description'   => t('Enter an amount above %base-bid-amount.',
      array('%base-bid-amount' => $form['bid']['#current_bid'])),
    '#attributes'    => null,
    '#required'      => true,
  );
  $form['bid']['#high_bid']     = auction_bid_current($edit['nid']);
  $form['bid']['#current_bid']  = !empty($form['bid']['#high_bid']['bid']) ?
    $form['bid']['#high_bid']['bid'] : $product->price;

  $form['nid'] = array(
    '#type'          => 'hidden',
    '#value'         => $edit['nid'],
  );
  $form['price'] = array(
    '#type'          => 'hidden',
    '#value'         => $form['bid']['#current_bid'],
  );
  $form['submit'] = array(
    '#type'          => 'submit',
    '#value'         => t('Confirm bid'),
  );
  return $form;
}
?>