XF 2.0 how to insert data in database on submit....?

lovnesh

Member
i want to insert data into database by controller . when i submit a from i get data in controller with filter function . how can i insert this data in database
 
thanks for help me..

rest one more thing how can i show retrive data in template39190049_2040192529567119_3232980299272945664_n.webp

i am trying to the title with this {$discord_title} but it giving me nothing this is what i try to do
 
thanks for help me..

rest one more thing how can i show retrive data in templateView attachment 181692

i am trying to the title with this {$discord_title} but it giving me nothing this is what i try to do

I always create a code event listener for the templater_template_pre_render event.
Then you can just add your template 'variable' the $params array - where the key is the name of the template variable.
(i.e. $params["discord_title"] = "...";)

(I'm not sure how well you know XF2 but I'll leave this here in case you aren't very familiar with code event listeners: https://xenforo.com/xf2-docs/dev/lets-build-an-add-on/#extending-the-forum-entity)
 
I always create a code event listener for the templater_template_pre_render event.
Then you can just add your template 'variable' the $params array - where the key is the name of the template variable.
(i.e. $params["discord_title"] = "...";)

(I'm not sure how well you know XF2 but I'll leave this here in case you aren't very familiar with code event listeners: https://xenforo.com/xf2-docs/dev/lets-build-an-add-on/#extending-the-forum-entity)


thanks for the info he is my patner thats by i am replying

We trying to do it without entity becasue i am confuse
what shoud i choose here

1534341896509-png.181693



i have allready created this in ENTITY directory ->
Code:
class Disocrdlist extends \XF\Mvc\Entity\Entity
{
$structure->table = 'xf_discord_list';
$structure->shortName = 'XF:DiscordList';
$structure->primaryKey = 'discord_id';
$structure->columns = [
'discord_id' => ['type' => self::UINT, 'autoIncrement' => true, 'required' => true],
'discord_title' => ['type' => self::UINT, 'required' => true],
'discord_desc' => ['type' => self::UINT, 'required' => true],
];
$structure->getters = [];
$structure->relations = [];

return $structure;
}
 
thanks for the info he is my patner thats by i am replying

We trying to do it without entity becasue i am confuse
what shoud i choose here

1534341896509-png.181693



i have allready created this in ENTITY directory ->
Code:
class Disocrdlist extends \XF\Mvc\Entity\Entity
{
$structure->table = 'xf_discord_list';
$structure->shortName = 'XF:DiscordList';
$structure->primaryKey = 'discord_id';
$structure->columns = [
'discord_id' => ['type' => self::UINT, 'autoIncrement' => true, 'required' => true],
'discord_title' => ['type' => self::UINT, 'required' => true],
'discord_desc' => ['type' => self::UINT, 'required' => true],
];
$structure->getters = [];
$structure->relations = [];

return $structure;
}
Oh, I just provided a specific example. You don't have to extend the forum entity but that guide also shows you how to create a code event listener.
 
Back
Top Bottom