Code: Select all
$config->set('test_id', $request->variable('test_id', 0));
But when I put e.g.: "2,3,4", config will update to "2". Why is that? Why is comma reduced and also everything after?
Code: Select all
$config->set('test_id', $request->variable('test_id', 0));
2,3,4 is not an INT. Maybe you're looking for an array?Trubs wrote: ↑Sat Oct 06, 2018 12:48 pmCode: Select all
$config->set('test_id', $request->variable('test_id', 0));
Yeah. I wasn't sure how variable works. Thankskinerity wrote: ↑Sat Oct 06, 2018 1:32 pm2,3,4 is not an INT. Maybe you're looking for an array?Trubs wrote: ↑Sat Oct 06, 2018 12:48 pmCode: Select all
$config->set('test_id', $request->variable('test_id', 0));
Passing an array as 2nd argument to
variable()
only works for field names ending with []
, for example ids[]=1&ids[]=2
. As far as I'm aware there's no type you can pass that makes it split a string for you.Not necessarily. If you only ever need to store a handful of IDs, using $config is perfectly fine. Why not go the manual way:
Code: Select all
$ids = $request->variable('ids', ''); // get as string
$ids = explode(',', $ids); // to array
$ids = array_filter(array_map('intval', $ids)); // filter integers
$ids = implode(',', $ids); // back to string
$config->set('ids', $ids); // store string
Code: Select all
/* Steam original colors set*/
array('config.add', array('threedi_steamsuite_css_colors', json_encode(array(
'vp_bkg' => '#273B52',
'vp_ing' => '#90ba3c',
'vp_onl' => '#66C0F4',
'vp_ofl' => '#898989',
'vt_bkg' => '#273B52',
'vt_ing' => '#90ba3c',
'vt_onl' => '#66C0F4',
'vt_ofl' => '#898989',
'icondark' => false,
)
)
)
),
Code: Select all
$color_configs = json_decode($config['threedi_steamsuite_css_colors'], true);
$request->variable
Code: Select all
$color_configs['vp_bkg'] = $request->variable('vp_bkg', $color_configs['vp_bkg']);
$color_configs['vp_ing'] = $request->variable('vp_ing', $color_configs['vp_ing']);
$color_configs['vp_onl'] = $request->variable('vp_onl', $color_configs['vp_onl']);
$color_configs['vp_ofl'] = $request->variable('vp_ofl', $color_configs['vp_ofl']);
$color_configs['vt_bkg'] = $request->variable('vt_bkg', $color_configs['vt_bkg']);
$color_configs['vt_ing'] = $request->variable('vt_ing', $color_configs['vt_ing']);
$color_configs['vt_onl'] = $request->variable('vt_onl', $color_configs['vt_onl']);
$color_configs['vt_ofl'] = $request->variable('vt_ofl', $color_configs['vt_ofl']);
$color_configs['icondark'] = $request->variable('icondark', $color_configs['icondark']);
$config->set('threedi_steamsuite_css_colors', json_encode($color_configs));
Thank you! That's what I was trying to say and I guess it came out wrong.