Textbox not populating

silence

Well-known member
SO! I'm extending Merc's donation manager, and everything is working so far, except one astetic thing:
The text field that I'm inputting info isn't being populated with the information currently stored in the db. If I write something and save, it populates the database just fine! It just doesn't show that info.

The only thing I THINK is causing it is some issue with _getFields():

PHP:
    protected function _getFields()
    {
        $fields = parent::_getFields();
 
        $fields['merc_goal']['merc_callback_class'] = array(
            'type'  => self::TYPE_STRING,
            'required' => false,
            'default' => '',
            'maxLength' => 250,
            'requiredError' => 'please_enter_valid_callback_class'
        );
 
        $fields['merc_goal']['merc_callback_method'] = array(
            'type' => self::TYPE_STRING,
            'required' => false,
            'default' => '',
            'maxLength' => 250,
            'requiredError' => 'please_enter_valid_callback_method'
        );
 
        return $fields;
    }
 
HTML:
<xen:controlunit label="{xen:phrase php_callback}:">
 
<xen:textbox name="merc_callback_class" value="{$field.merc_callback_class}" placeholder="{xen:phrase class}" size="25" />
 
::
 
<xen:textbox name="merc_callback_method" value="{$field.merc_callback_method}" placeholder="{xen:phrase method}" size="25" />
 
</xen:controlunit>
Derp yeah you were right. Thanks mate!
 
Did you set the proper <input> value parameter?
One more question:
I'm extending a model blahblahblah, and I'm extending one of it's functions:

PHP:
    public function commit($token)
    {
        $this->finalizeCallback($token);
       
        return parent::commit($token);
    }
However, it completely breaks the function commit in the model I'm extending. I thought returning the parent should make it execute as normal but that doesn't seem to work. What is the safest way to do this?
 
One more question:
I'm extending a model blahblahblah, and I'm extending one of it's functions:

PHP:
    public function commit($token)
    {
        $this->finalizeCallback($token);
   
        return parent::commit($token);
    }
However, it completely breaks the function commit in the model I'm extending. I thought returning the parent should make it execute as normal but that doesn't seem to work. What is the safest way to do this?

I can't comment without seeing the whole code, but you're basically returning the result of the parent function, which is equal to not overriding the function at all.
 
I can't comment without seeing the whole code, but you're basically returning the result of the parent function, which is equal to not extending the function at all.
How would you extend a function in XF? And I'm not posting the code since it's a paid plugin and I feel permission from the author would be needed.
 
Sorry, I meant overriding.
Ok I'm still lost. I'm extending the model in my listener.php file, and i created the code listener in XF.
This is what I'm doing:

PHP:
    public static function loadClassModel($class, array &$extend)
    {       
        if ($class == 'Merc_DonationManager_Model_Goal')
            $extend[] = 'XenoGamers_Model_Goal';
        elseif ($class == 'Merc_DonationManager_Model_Transaction')
            $extend[] = 'XenoGamers_Model_Transaction';
    }
 
Really can't comment without seeing the entire code. What does finalizeCallback do?

PHP:
    protected function finalizeCallback($token)
    {
        $transaction = $this->getTransaction($token);
 
        $fields = Merc_DonationManager_DataWriter_Goal::_getFields();
 
        $entry = array(
            'username' => $this->getModelFromCache('XenForo_Model_User')->getUserById($transaction['user_id']),
            'user_id' => $transaction['user_id'],
            'goal_id' => $transaction['goal_id'],
            'amount' => $transaction['amount'],
            'note' => $transaction['note'],
            'anonymous' => $transaction['anonymous'],
            'merc_callback_class' => $fields['merc_callback_class'],
            'merc_callback_method' => $fields['merc_callback_method']
        );
 
        $this->_getTransactionModel()->executeCallback($entry);
    }
 
    protected function _getTransactionModel()
    {
        return $this->getModelFromCache('Merc_DonationManager_DataWriter_Goal');
    }
 
start debugging! (use a php debugger or stupid echo/var_dump commands)
$fields = Merc_DonationManager_DataWriter_Goal::_getFields(); won't work

1. The method isn't static
2. it's not a public method
 
start debugging! (use a php debugger or stupid echo/var_dump commands)
$fields = Merc_DonationManager_DataWriter_Goal::_getFields(); won't work

1. The method isn't static
2. it's not a public method

Ok I rewrote everything so in datawriter it calls a single model file. The only issue I have now is that how do I get the custom callback to execute? Here is the final model:

PHP:
class XenoGamers_Model_Callback extends XenForo_Model
{
    public function executeCallback(array $entry, array $callback)
    {
        if (XenForo_Application::autoload($callback['callback_class']) && method_exists($callback['callback_class'], $callback['callback_method']))
        {
            call_user_func(array($callback['callback_class'], $callback['callback_method']), $entry);
        }
    }
}
 
Anyone know how to execute a callback in the way I described above? I can't find anything in the xf core.
 
Top Bottom