Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
98996b52
Commit
98996b52
authored
Jul 17, 2012
by
jhodgdon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1681456
by mjonesdinero: Move hook_field_widget_properties_alter to correct group
parent
7e1becfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
core/modules/field/field.api.php
core/modules/field/field.api.php
+32
-32
No files found.
core/modules/field/field.api.php
View file @
98996b52
...
...
@@ -935,6 +935,38 @@ function hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $cont
$element
[
'#autocomplete_path'
]
=
'mymodule/autocomplete_path'
;
}
/**
* Alters the widget properties of a field instance before it gets displayed.
*
* Note that instead of hook_field_widget_properties_alter(), which is called
* for all fields on all entity types,
* hook_field_widget_properties_ENTITY_TYPE_alter() may be used to alter widget
* properties for fields on a specific entity type only.
*
* This hook is called once per field per added or edit entity. If the result
* of the hook involves reading from the database, it is highly recommended to
* statically cache the information.
*
* @param $widget
* The instance's widget properties.
* @param $context
* An associative array containing:
* - entity_type: The entity type; e.g., 'node' or 'user'.
* - entity: The entity object.
* - field: The field that the widget belongs to.
* - instance: The instance of the field.
*
* @see hook_field_widget_properties_ENTITY_TYPE_alter()
*/
function
hook_field_widget_properties_alter
(
&
$widget
,
$context
)
{
// Change a widget's type according to the time of day.
$field
=
$context
[
'field'
];
if
(
$context
[
'entity_type'
]
==
'node'
&&
$field
[
'field_name'
]
==
'field_foo'
)
{
$time
=
date
(
'H'
);
$widget
[
'type'
]
=
$time
<
12
?
'widget_am'
:
'widget_pm'
;
}
}
/**
* Flag a field-level validation error.
*
...
...
@@ -2327,38 +2359,6 @@ function hook_field_extra_fields_display_alter(&$displays, $context) {
}
}
/**
* Alters the widget properties of a field instance before it gets displayed.
*
* Note that instead of hook_field_widget_properties_alter(), which is called
* for all fields on all entity types,
* hook_field_widget_properties_ENTITY_TYPE_alter() may be used to alter widget
* properties for fields on a specific entity type only.
*
* This hook is called once per field per added or edit entity. If the result
* of the hook involves reading from the database, it is highly recommended to
* statically cache the information.
*
* @param $widget
* The instance's widget properties.
* @param $context
* An associative array containing:
* - entity_type: The entity type; e.g., 'node' or 'user'.
* - entity: The entity object.
* - field: The field that the widget belongs to.
* - instance: The instance of the field.
*
* @see hook_field_widget_properties_ENTITY_TYPE_alter()
*/
function
hook_field_widget_properties_alter
(
&
$widget
,
$context
)
{
// Change a widget's type according to the time of day.
$field
=
$context
[
'field'
];
if
(
$context
[
'entity_type'
]
==
'node'
&&
$field
[
'field_name'
]
==
'field_foo'
)
{
$time
=
date
(
'H'
);
$widget
[
'type'
]
=
$time
<
12
?
'widget_am'
:
'widget_pm'
;
}
}
/**
* Alters the widget properties of a field instance on a given entity type
* before it gets displayed.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment