Jake B.
Well-known member
We need to be able to set a field to null for some certain circumstances. However, when I try to pass null to the DataWriter it defaults it to a Zero, which has a separate meaning. Right now we have this:
NULL = Use global setting for this field
0 = Disable this setting for this location only
1+ = Number of seconds for advertisement to show up.
Relevant code:
data being passed to DataWriter:
DataWriter field definitions:
NULL = Use global setting for this field
0 = Disable this setting for this location only
1+ = Number of seconds for advertisement to show up.
Relevant code:
data being passed to DataWriter:
Code:
$rotateSpeedStr = $this->_input->filterSingle('rotate_speed', XenForo_Input::STRING);
$rotateSpeed = $this->_input->filterSingle('rotate_speed', XenForo_Input::UINT);
$writerData = $this->_input->filter(array(
'title' => XenForo_Input::STRING,
'hook_name' => XenForo_Input::STRING,
'active' => XenForo_Input::UINT,
'global' => XenForo_Input::UINT,
));
$writerData['rotate_speed'] = $rotateSpeed;
if (empty($rotateSpeedStr))
{
$writerData['rotate_speed'] = 'null';
}
DataWriter field definitions:
Code:
protected function _getFields()
{
return array(
'admonetize_advertisement_spot' => array(
'spot_id' => array('type' => self::TYPE_UINT, 'autoIncrement' => true),
'title' => array('type' => self::TYPE_STRING, 'maxLength' => 50, 'required' => true),
'hook_name' => array('type' => self::TYPE_STRING, 'maxLength' => 50, 'required' => true),
'active' => array('type' => self::TYPE_UINT, 'maxLength' => 1, 'default' => 1),
'global' => array('type' => self::TYPE_UINT, 'maxLength' => 1, 'default' => 0),
'rotate_speed' => array('type' => self::TYPE_UINT, 'default' => 'null'),
)
);
}