When non-required cck date fields are left blank in my nodes, the corresponding fields in the PDF are filled with the current date and time. Since these fields are optional, I'd expect that the PDF fields would be blank.

I've confirmed that the fields have no default value, no date values are saved to the database when the field is left blank, and all the field mappings in the Fill PDF settings are correct.

I need to find at least a temporary fix for this, so any advice would be much appreciated. Thanks in advance.

Comments

wizonesolutions’s picture

Status: Active » Postponed (maintainer needs more info)

My thoughts: at first glance, this is a Token issue. Fill PDF doesn't alter date values in any way prior to filling them in. Does this also happen in the -dev version?

I would search the Token issue queue to see if anyone has reported this there. If you are using a formatted date token (e.g. :medium), try using the date token straight and see what happens.

Let me know.

jeastham’s picture

Category: bug » support
Priority: Major » Normal

Thanks for your help. It did turn out to be an issue with Token, as reported in this thread: http://drupal.org/node/1506450. Unfortunately, the easiest fix at the moment is to modify the Token module to return an empty string when date fields are empty.

wizonesolutions’s picture

Version: 7.x-1.4 » 7.x-1.x-dev

Ack, that's a nasty one. I'll leave this open to see if a workaround can be implemented somehow. After all, I do know what data is being sent to the token before it's done, so I can check for a discrepancy and manually blank it out before it's sent to the PDF (or just skip that field and blank it out, etc.).

Thanks for reporting this.

wizonesolutions’s picture

Status: Postponed (maintainer needs more info) » Active
wizonesolutions’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Category: support » bug
Issue tags: +Date token, +fillpdf2
wizonesolutions’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Issue summary: View changes
Issue tags: -Date token, -fillpdf2

The related issue isn't fixed, but I'm not going to do anything on my end. A contrib solution might exist.

wizonesolutions’s picture

Status: Active » Closed (won't fix)
mattplu’s picture

I know this was a while ago but I am pulling my hair out trying to figure out where to change anything to leave a blank date blank. Anyone successfully fix this? I will even go so far as to change core at this point if I need to!

mattplu’s picture

In case anyone comes across this, I know it is a ridiculous solution but it works for me. It checks if the token contains ':custom:m/d/Y]' (all of my dates do but change this to something unique about yours) and if it does and is equal to "" then it just unsets the object for that one so it can't return any value.

// --- node token replacements
      if (!empty($nodes)) {
        foreach ($nodes as $node) {
          $token_objects['node'] = $node;
		  
		  
			//Custom Code - Get field name from $obj-value and if equal to "", unset $obj
			$strlen = ($obj->value);
		    $left_side = strpos($obj->value, '[node:');
            $right_side = strpos($obj->value, '');
            $field_name = substr($obj->value, 6, $strlen - 14);
			$newfieldname = str_replace("-","_",$field_name);
			
			$returnVal = field_get_items('node',$node, $newfieldname);
			$testVal = $returnVal[0]['value'];
		  
		//watchdog('fillpdf', 'Watchdog "%form" for node value "%node" with test of "%test".', array(
		//		'%form' => $obj->value,
		//		'%test' => $newfieldname,
		//		'%node' => $testVal,));
				
			if (strstr($obj->value, ':custom:m/d/Y]') && $testVal == "") { unset($obj); }
steven-spencer’s picture

#9 worked for me, fillpdf.module - version = "7.x-1.14" line 521