function merci_line_item_handler_field_edit_quantity::views_form in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Returns the form which replaces the placeholder from render().
File
- merci_line_item/
includes/ views/ handlers/ merci_line_item_handler_field_edit_quantity.inc, line 31 - Field handler to present a form field to change quantity of a line item. It's a dummy handler, most part of the implementation is done via post render hook.
Class
- merci_line_item_handler_field_edit_quantity
- Field handler to present a field to change quantity of a line item.
Code
function views_form(&$form, &$form_state) {
// The view is empty, abort.
if (empty($this->view->result)) {
return;
}
$form[$this->options['id']] = array(
'#tree' => TRUE,
);
// At this point, the query has already been run, so we can access the results
// in order to get the base key value (for example, nid for nodes).
foreach ($this->view->result as $row_id => $row) {
$line_item_id = $this
->get_value($row, 'line_item_id');
$quantity = $this
->get_value($row, 'quantity');
$form[$this->options['id']][$row_id] = array(
'#type' => 'textfield',
'#datatype' => 'integer',
'#default_value' => round($quantity),
'#size' => 4,
'#maxlength' => max(4, strlen($quantity)),
'#line_item_id' => $line_item_id,
'#attributes' => array(
'title' => $this->options['label'],
),
);
}
}