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

prepDataForWrite( (object | string | int) $element_identifier, (array | string | int) $value, (int) $entry_id )

Location

/modules/formulize/include/functions.php

Description

Prepares a value submitted through a form, for saving into the database. Values submitted from a form do not always conform to the storage format that is used in the database, or may need validation.

Values passed to this function do not have to be from a form. Values must simply conform to the format that would be provided by a form submission.

Parameters

$element_identifier - either an element id, an element handle, or a Formulize element object
$value - the value to be prepared
$entry_id - The entry id for which the value is being prepared, or “new” for a new entry. This does not always have an effect, but in some situations the particular entry might affect what happens to the value.

Return Values

Returns the prepared value.

Returns false if the element_identifier is invalid.

Examples

// radio buttons submit the ordinal number of the option that was selected
// convert a 3 to the text for the third radio button option
// entry id we are going to write to is 27
$value = prepDataForWrite('fruit_choices', 3, 27);
// take a date value and prepare it for saving into a date element in a new entry in the database
$value = "May 9, 1969";
$value = prepDataForWrite('date_element_handle', $value, 'new');