Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
7cd59c6b
Commit
7cd59c6b
authored
15 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#548630
by bjaspan: Document hook_field_is_empty().
parent
1724844d
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/field/field.api.php
+19
-0
19 additions, 0 deletions
modules/field/field.api.php
with
19 additions
and
0 deletions
modules/field/field.api.php
+
19
−
0
View file @
7cd59c6b
...
...
@@ -125,6 +125,7 @@ function hook_fieldable_info_alter(&$info) {
* @see hook_field_delete().
* @see hook_field_delete_revision().
* @see hook_field_sanitize().
* @see hook_field_is_empty().
*
* The Field Types API also defines two kinds of pluggable handlers: widgets
* and formatters, which specify how the field appears in edit forms and in
...
...
@@ -518,6 +519,24 @@ function hook_field_delete_revision($obj_type, $object, $field, $instance, $item
function
hook_field_prepare_translation
(
$obj_type
,
$object
,
$field
,
$instance
,
$items
)
{
}
/**
* Define what constitutes an empty item for a field type.
*
* @param $item
* An item that may or may not be empty.
* @param $field
* The field to which $item belongs.
* @return
* TRUE if $field's type considers $item not to contain any data;
* FALSE otherwise.
*/
function
hook_field_is_empty
(
$item
,
$field
)
{
if
(
empty
(
$item
[
'value'
])
&&
(
string
)
$item
[
'value'
]
!==
'0'
)
{
return
TRUE
;
}
return
FALSE
;
}
/**
* Expose Field API widget types.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment