emiya
Member
Hi,
I'm currently working on a self-made addon that extends the Userupgrade class. I added a custom input field on the ACP user upgrade edit page (following the Let's Build an Addon guide) and on the step where I need to extend the save process I get an error:
This is the code in my foo\addon\XF\Admin\Controller\UserUpgrade.php
This is the code in my Listener.php
And that's the content of the function in XF\Admin\Controller\UserUpgrade.php
I know that something is messed up and no data is given through the code, but what did I wrong and how can I prevent this in the future?
Kind regards
I'm currently working on a self-made addon that extends the Userupgrade class. I added a custom input field on the ACP user upgrade edit page (following the Let's Build an Addon guide) and on the step where I need to extend the save process I get an error:
This is the code in my foo\addon\XF\Admin\Controller\UserUpgrade.php
PHP:
class UserUpgrade extends XFCP_UserUpgrade
{
protected function upgradeSaveProcess(\XF\Entity\UserUpgrade $upgrade)
{
parent::upgradeSaveProcess($upgrade);
$form = $this->formAction();
$form->setup(function() use ($upgrade)
{
$upgrade->old_costs_amount = $this->filter('old_costs_amount', 'unum');
});
}
}
This is the code in my Listener.php
PHP:
use XF\Mvc\Entity\Entity;
class Listener
{
public static function userupgradeEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
{
$structure->columns['old_costs_amount'] = ['type' => Entity::FLOAT, 'default' => 0, 'max' => 99999999, 'min' => 0];
}
}
And that's the content of the function in XF\Admin\Controller\UserUpgrade.php
PHP:
protected function upgradeSaveProcess(\XF\Entity\UserUpgrade $upgrade)
{
$form = $this->formAction();
$input = $this->filter([
'title' => 'str',
'description' => 'str',
'display_order' => 'uint',
'extra_group_ids' => 'array-uint',
'recurring' => 'bool',
'cost_amount' => 'unum',
'cost_currency' => 'str',
'length_amount' => 'uint',
'length_unit' => 'string',
'payment_profile_ids' => 'array-uint',
'disabled_upgrade_ids' => 'array-uint',
'can_purchase' => 'bool'
]);
$form->basicEntitySave($upgrade, $input);
$form->setup(function() use($upgrade)
{
if ($this->filter('length_type', 'str') == 'permanent')
{
$upgrade->length_amount = 0;
$upgrade->length_unit = '';
}
});
return $form;
}
I know that something is messed up and no data is given through the code, but what did I wrong and how can I prevent this in the future?
Kind regards