DrupalBin
Submit Code
About
Recent Posts
Code
Fix for Fix for Code
Fix for Code
Code
Node type whitelist
an axe coach accessories
coach purses married
Fix for de las ghd alturas
de las ghd alturas
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
Fix for Attempt at a custom element to represent a 24 hour clock.
View
Fix
October 7, 2008 - 11:39am — Anonymous
<?php
// $Id
function
timeform_element_menu
(
)
{
$items
[
'timeform/element'
]
=
array
(
'title'
=
>
'Test timeform element'
,
'page callback'
=
>
'drupal_get_form'
,
'page arguments'
=
>
array
(
'timeform_element_form'
)
,
'access arguments'
=
>
array
(
'access content'
)
,
)
;
return
$items
;
}
function
timeform_element_elements
(
)
{
$type
[
'timeform'
]
=
array
(
'#input'
=
>
TRUE
,
'#process'
=
>
array
(
'timeform_element_time_expand'
)
,
'#element_validate'
=
>
array
(
'timeform_element_time_validate'
)
,
)
;
return
$type
;
}
function
timeform_element_time_expand
(
$element
)
{
$element
[
'#tree'
]
=
TRUE
;
if
(
!
isset
(
$element
[
'#value'
]
)
)
{
$element
[
'#value'
]
=
array
(
'hour'
=
>
0
,
'minute'
=
>
0
)
;
}
$element
[
'hour'
]
=
array
(
'#type'
=
>
'select'
,
'#default_value'
=
>
variable_get
(
'feed_item_length'
, 00
)
,
'#options'
=
>
array
(
00,01,02,03,04,05,06,07,08,09,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
)
,
'#required'
=
>
TRUE
,
)
;
$element
[
'minute'
]
=
array
(
'#type'
=
>
'select'
,
'#default_value'
=
>
variable_get
(
'feed_item_length'
, 00
)
,
'#options'
=
>
array
(
00,01,02,03,04,05,06,07,08,09,
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
)
,
'#required'
=
>
TRUE
,
'#prefix'
=
>
t
(
':'
)
,
)
;
return
$element
;
}
function
timeform_element_time_validate
(
$form
,
&
$form_state
)
{
return
$form
;
}
function
timeform_element_theme
(
)
{
return
array
(
'timeform'
=
>
array
(
'arguments'
=
>
array
(
'element'
)
,
)
,
)
;
}
function
theme_timeform
(
$element
)
{
return
theme
(
'form_element'
,
$element
,
'<div class="container-inline">'
.
$element
[
'#children'
]
.
'</div>'
)
;
}
function
timeform_element_form
(
)
{
return
system_settings_form
(
$form
)
;
}
Custom Element
fapi
module
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php // $Id function timeform_element_menu() { $items['timeform/element'] = array( 'title' => 'Test timeform element', 'page callback' => 'drupal_get_form', 'page arguments' => array('timeform_element_form'), 'access arguments' => array('access content'), ); return $items; } function timeform_element_elements() { $type['timeform'] = array( '#input' => TRUE, '#process' => array('timeform_element_time_expand'), '#element_validate' => array('timeform_element_time_validate'), ); return $type; } function timeform_element_time_expand($element) { $element['#tree'] = TRUE; if (!isset($element['#value'])) { $element['#value'] = array( 'hour' => 0, 'minute' => 0); } $element['hour'] = array( '#type' => 'select', '#default_value' => variable_get('feed_item_length', 00), '#options' => array(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23), '#required' => TRUE, ); $element['minute'] = array( '#type' => 'select', '#default_value' => variable_get('feed_item_length', 00), '#options' => array(00,01,02,03,04,05,06,07,08,09,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), '#required' => TRUE, '#prefix' => t(':'), ); return $element; } function timeform_element_time_validate($form, &$form_state) { return $form; } function timeform_element_theme() { return array( 'timeform' => array( 'arguments' => array('element'), ), ); } function theme_timeform($element) { return theme('form_element', $element, '<div class="container-inline">' . $element['#children'] . '</div>'); } function timeform_element_form() { return system_settings_form($form); }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp phps
.