function commerce_invoice_number_pattern_form in Commerce Invoice 7.2
Form callback for an invoice number pattern.
Parameters
array $form:
array &$form_state:
\Drupal\commerce_invoice\Entity\InvoiceNumberPattern $pattern:
string $op:
Return value
array
File
- ./
commerce_invoice.admin.inc, line 35 - Administrative form and page callbacks for the Commerce Invoice module.
Code
function commerce_invoice_number_pattern_form($form, &$form_state, \Drupal\commerce_invoice\Entity\InvoiceNumberPattern $pattern, $op = 'edit') {
$form['label'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $pattern->label,
'#required' => TRUE,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => $pattern->name,
'#disabled' => entity_has_status('commerce_invoice_number_pattern', $pattern, ENTITY_IN_CODE) || $op === 'edit',
'#machine_name' => array(
'exists' => 'commerce_invoice_number_pattern_load',
'source' => array(
'label',
),
),
'#description' => t('A unique machine-readable name for this pattern. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['pattern'] = array(
'#type' => 'textfield',
'#title' => t('Pattern'),
'#description' => t('The pattern for invoice numbers.') . '<br />' . t('By default an integer will be appended. Include the special token <code>@sequence_token</code> to place the integer manually.', array(
'@sequence_token' => \Drupal\commerce_invoice\InvoiceNumber\InvoiceNumber::SEQUENCE_TOKEN,
)) . '<br />' . t('This integer is calculated sequentially based on the pattern (after system tokens have been replaced).'),
'#default_value' => $pattern->pattern,
'#required' => TRUE,
);
$form['skip_sequence'] = array(
'#type' => 'checkbox',
'#title' => t('Hide sequence integer'),
'#description' => t('Do not append sequence integer to the invoice number pattern.') . '<br />' . t('WARNING: If you check the checkbox, make sure the above pattern provides unique invoice numbers. Failure to do so may result in multiple invoices with same numbers.'),
'#default_value' => $pattern->skip_sequence,
);
$form['token_help'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
'date',
'site',
'commerce_invoice',
),
'#global_types' => FALSE,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}