-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajf.form.dynamic.radios.states.inc
More file actions
61 lines (60 loc) · 1.89 KB
/
ajf.form.dynamic.radios.states.inc
File metadata and controls
61 lines (60 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Uses radios to determine which form fields to display to the user.
*
* This does a built-in ajax call based on the '#states' and 'visible' array elements
* on the dynamic fields.
*/
// Conditionaly display quantity and units fields.
$form['entry_type'] = array(
'#type' => 'radios',
'#title' => t('Entry Type'),
'#options' => drupal_map_assoc(
array(
t('Billed Amount'),
t('Quantity'),
)
),
'#default_value' => 'Billed Amount',
'#description' => t('Use Billed Amount if you only have one amount to charge. Select Quantity if have more than one of the same item to charge for.'),
);
$form['quantity'] = array(
'#type' => 'textfield',
'#title' => t('Quantity'),
'#default_value' => '1',
'#maxlength' => 9,
'#element_validate' => array('element_validate_number'),
'#description' => t('Enter the number of units sold.'),
'#states' => array(
'visible' => array(
':input[name="entry_type"]' => array('value' => t('Quantity'))
),
),
);
$form['unit_cost_amt'] = array(
'#type' => 'textfield',
'#title' => t('Unit Cost'),
'#default_value' => '0.00',
'#maxlength' => 12,
'#element_validate' => array('element_validate_number'),
'#description' => t('Enter the cost for one unit.'),
'#states' => array(
'visible' => array(
':input[name="entry_type"]' => array('value' => t('Quantity'))
),
),
);
$form['billed_amt'] = array(
'#type' => 'textfield',
'#title' => t('Billed Amount'),
'#default_value' => '0.00',
'#maxlength' => 12,
'#element_validate' => array('element_validate_number'),
'#description' => t('Enter the total amount billed for this item.'),
'#states' => array(
'visible' => array(
':input[name="entry_type"]' => array('value' => t('Billed Amount'))
),
),
);
// End conditional section.