/** * Inline callback to save a normal textfield * @param int $postId the id of the post to save to * @param array $field all the fields information * @param string $boxId the metabox id */ public function saveDateField($postId, $field, $boxId) { // Validate and save the field $value = $_POST[$postId . '_' . $field['key']]; $value = stripslashes(trim($value)); // Validate the input with EU_FORMAT_DATE if (!String::check_date($value, Date::EU_FORMAT_DATE)) { $value = ''; // Make the error pop up } // Check if the field is required if (isset($field['args']['required']) && $field['args']['required'] && strlen($value) == 0) { $this->addError($boxId, 'Bitte füllen Sie das Feld "' . $field['args']['title'] . '" aus.'); } else { // If everything OK, convert to the desired format if (strlen($value) > 0) { $value = Date::convert_date(Date::EU_DATE, $field['args']['format'], $value); } } // Save the meta data to the database update_post_meta($postId, $field['key'], $value); }