Formulize

Forms, workflows, and reporting. 100% free and open source.

Version 7.3 out now!How to installHow to update

Download .zip View on GitHub Join us on Slack Follow on Twitter

elementHasValueInEntry( (int) $entry_id, (int | string | object) $element_identifier )

Description

Checks if the given element has a value in the given entry.

Parameters

$entry_id - an entry id to query
$element_identifier - either an element id, an element handle, or a Formulize element object

Return Values

Returns true if the given element has a value in the given entry. Having a value means not being equal to an empty string, ie: $value != ""

Note that this is a non strict comparison in PHP so null values and zeros will return false, the same as empty strings.

Returns false if the given element does not have a value, or if the query fails, or if the element identifier is invalid.

Example

// check if the order_details form element has a value in entry 19 in form 6
$form_id = 6;
$dataHandler = new formulizeDataHandler($form_id);
$entry_id = 19;
$element_handle = "order_details";
if($dataHandler->elementHasValueInEntry($entry_id, $element_handle)) {
    echo "The order has details";
}