• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Input from option to database

kalco

Active member
#1
Hi to all,
I developing one add-on and i have one question.

So if possibility to insert data to database from option?
e.x
Screenshot_1.jpg

i have two option:

1. one text field
2. radio button with two option
(Same from inage above)

My database table is:

Code:
CREATE TABLE IF NOT EXISTS `xf_addon1` (
  `news_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  `show_description` tinyint(3) unsigned NOT NULL,


  PRIMARY KEY (`news_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
Can i make insert input from field direct to 'name' and from radio button direct to 'show_description' ?

Thank you
 

Robust

Well-known member
#2
You can get the XF options using XenForo_Application::getOptions()
Use magic accessors (if you like to call that, they have a real name) to access the options field. e.g. $options->theOptionID
Then run a db query as normal to put it in.