function pay::form_setup in Pay 6
Same name and namespace in other branches
- 7 includes/handlers/pay.inc \pay::form_setup()
2 calls to pay::form_setup()
- pay::form in includes/
handlers/ pay.inc - pay::settings_form in includes/
handlers/ pay.inc
File
- includes/
handlers/ pay.inc, line 187 - The base class for the Payment API.
Class
- pay
- @file The base class for the Payment API.
Code
function form_setup(&$form, &$form_state, $form_type = 'form') {
// By default, the settings form simply adds its identifiers to the form.
$handler = $this
->handler();
$key = $this->key;
// If the form has not been officially submitted, but the handler
// is present in $_REQUEST, it may be from a sub-form (e.g. an amount-only
// form). Set the POSTed values.
if (!$form_state['submitted'] && isset($_REQUEST[$handler])) {
foreach ($_REQUEST[$handler] as $posted_name => $posted_val) {
$func = 'set_' . $posted_name;
// It is up to the handler to sanitize the value in its set_* functions.
if (method_exists($this, $func)) {
$this
->{$func}($posted_val);
}
}
}
if (!isset($form['#pay'])) {
$form['#pay'] = array();
$form['#after_build'][] = 'pay_after_build';
}
$values = (array) $this;
$values['type'] = $this->table;
$values['form'] = $form_type;
$values['form_type'] = $form_state['pay_form_type'];
$class = array(
'pay',
'pay-' . $form_type,
'pay-' . $handler,
'pay-' . $form_type . '-' . $form_state['pay_form_type'],
);
$form['#attributes']['class'] = empty($form['#attributes']['class']) ? join(' ', $class) : $form['#attributes']['class'] . ' ' . join(' ', $class);
$form['#pay'][] = $values;
$form[$handler]['#tree'] = TRUE;
$form[$handler]['#group'] = $handler;
}