R
ragtek
Guest
The Method controller::_validateField($dataWriterName, array $data = array()) doesn't work 100% as it should.
It doesn't accept additional Data, which are set to the "normal" DataWriters.
Because of this, sometimes the validator will show an error which shouldn't be shown and the datawriter will be saved sucessfull.
For example:
XenForo_ControllerAdmin_User
If you edit an user from the acp, the dw have the Option OPTION_ADMIN_EDIT set to true, which will skip some validators
BUT, because of the js autovalidation , the script will call
And because of this we will get an validation error, because the dw doesn't skip the check (because of the missing OPTION_ADMIN_EDIT)!
What about a 3. parameter, where we can set the options?
instead of
and in controller::_validateField add the 3. parameter and inside
It doesn't accept additional Data, which are set to the "normal" DataWriters.
Because of this, sometimes the validator will show an error which shouldn't be shown and the datawriter will be saved sucessfull.
For example:
XenForo_ControllerAdmin_User
If you edit an user from the acp, the dw have the Option OPTION_ADMIN_EDIT set to true, which will skip some validators
PHP:
$writer->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
BUT, because of the js autovalidation , the script will call
PHP:
public function actionValidateField()
{
$this->_assertPostOnly();
return $this->_validateField('XenForo_DataWriter_User', array(
'existingDataKey' => $this->_input->filterSingle('user_id', XenForo_Input::UINT)
));
}
And because of this we will get an validation error, because the dw doesn't skip the check (because of the missing OPTION_ADMIN_EDIT)!
What about a 3. parameter, where we can set the options?
PHP:
public function actionValidateField()
{
$this->_assertPostOnly();
return $this->_validateField('XenForo_DataWriter_User', array(
'existingDataKey' => $this->_input->filterSingle('user_id', XenForo_Input::UINT)
), array(XenForo_DataWriter_User::OPTION_ADMIN_EDIT));
}
PHP:
public function actionValidateField()
{
$this->_assertPostOnly();
return $this->_validateField('XenForo_DataWriter_User', array(
'existingDataKey' => $this->_input->filterSingle('user_id', XenForo_Input::UINT)
));
}
and in controller::_validateField add the 3. parameter and inside
PHP:
protected function _validateField($dataWriterName, array $data = array(), array $options = array())
....
if (!empty($options)){
foreach ($options AS $option => $value)
$writer->setOption($option, $value);
}