Advertisement:

Author Topic: Params::setParam- meta  (Read 2155 times)

serjuc11111

  • Hero Member
  • *****
  • Posts: 812
Params::setParam- meta
« on: November 08, 2016, 04:39:10 pm »
I have a meta input like :
<input id="meta_new-custom-field" name="meta[42]" value="" type="text">
how to set params for this input:?
Params::setParam("meta[42]","0123456789");//not working
$_POST[meta[42]] = '0123456789';//not workig too
meta field: pk_i_id - 42 s_name -> Phone* ,
thx!

serjuc11111

  • Hero Member
  • *****
  • Posts: 812
Re: Params::setParam- meta
« Reply #1 on: November 08, 2016, 07:51:01 pm »
No help for this one?What im doing wrong....??

serjuc11111

  • Hero Member
  • *****
  • Posts: 812
[solved]Re: Params::setParam- meta
« Reply #2 on: November 08, 2016, 08:39:41 pm »
If you will need to solve this ,use
where $br=fk_i_field_id
 Params::setParam('meta',array($br=>'0123456789'));

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: [solved]Re: Params::setParam- meta
« Reply #3 on: March 28, 2019, 10:57:55 pm »
If you will need to solve this ,use
where $br=fk_i_field_id
 Params::setParam('meta',array($br=>'0123456789'));

how did you solve this? please share with us!
i want to get and set the value of a custom-field in item-post.php

$get_value = Params::getParam('meta[42]'); //Getting the value = Not working!
Params::setParam('meta[42]', '999'); //Setting the value = Not working!

WEBmods

  • Hero Member
  • *****
  • Posts: 872
Re: [solved]Re: Params::setParam- meta
« Reply #4 on: March 28, 2019, 11:09:46 pm »
If you will need to solve this ,use
where $br=fk_i_field_id
 Params::setParam('meta',array($br=>'0123456789'));

how did you solve this? please share with us!
i want to get and set the value of a custom-field in item-post.php

$get_value = Params::getParam('meta[42]'); //Getting the value = Not working!
Params::setParam('meta[42]', '999'); //Setting the value = Not working!

meta is an ARRAY. Which means getParam('meta[field_id]') won't work, you need to get meta variable and access it's key - getParam('meta')['field_id']. Probably same for setParam, never used that function so...

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #5 on: March 29, 2019, 06:49:36 pm »
If you will need to solve this ,use
where $br=fk_i_field_id
 Params::setParam('meta',array($br=>'0123456789'));

how did you solve this? please share with us!
i want to get and set the value of a custom-field in item-post.php

$get_value = Params::getParam('meta[42]'); //Getting the value = Not working!
Params::setParam('meta[42]', '999'); //Setting the value = Not working!

meta is an ARRAY. Which means getParam('meta[field_id]') won't work, you need to get meta variable and access it's key - getParam('meta')['field_id']. Probably same for setParam, never used that function so...

Regards.

what is the format for setting?

Params::setParam('meta[42]', '$cf_value'); //Not working!
Params::setParam(('meta')[42], '$cf_value'); //Parse error: syntax error, unexpected '[' in ...
« Last Edit: March 29, 2019, 06:52:59 pm by Sophia_OS »

WEBmods

  • Hero Member
  • *****
  • Posts: 872
Re: Params::setParam- meta
« Reply #6 on: March 29, 2019, 07:14:22 pm »
Try this:

Code: [Select]
$old_meta = Params::getParam('meta');
$new_meta = $old_meta;
$new_meta[42] = 'Value for field 42';
Params::setParam('meta', $new_meta);

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #7 on: March 30, 2019, 09:48:56 pm »
Try this:

Code: [Select]
$old_meta = Params::getParam('meta');
$new_meta = $old_meta;
$new_meta[42] = 'Value for field 42';
Params::setParam('meta', $new_meta);

Regards.

i put this code in header, but when i load item-post.php, custom-field-42 didn't get "Value for field 42" value on page-load! and it was empty!

WEBmods

  • Hero Member
  • *****
  • Posts: 872
Re: Params::setParam- meta
« Reply #8 on: March 30, 2019, 10:08:33 pm »
Where exactly do you want to get and modify this meta field?

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #9 on: March 31, 2019, 11:34:18 pm »
Where exactly do you want to get and modify this meta field?

Regards.

in item-post.php i want to get and replace! (posted_item hook)
not with sql, i just want to get the value of CF and replace it!

WEBmods

  • Hero Member
  • *****
  • Posts: 872
Re: Params::setParam- meta
« Reply #10 on: April 01, 2019, 09:00:06 am »
Try doing that in pre_item_post. Param is already saved when posted_item runs.

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #11 on: April 01, 2019, 09:01:52 pm »
Try doing that in pre_item_post. Param is already saved when posted_item runs.
Regards.

Not working!
I even put that code directly in header.php and didn't work!

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #12 on: April 19, 2019, 09:47:53 am »
@patrickFromCroatia
Did you find a way to do this?

WEBmods

  • Hero Member
  • *****
  • Posts: 872
Re: Params::setParam- meta
« Reply #13 on: April 19, 2019, 01:03:01 pm »
So you want to change the value of the meta param before it's saved in the database? Or can you update it in the database later?

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 422
Re: Params::setParam- meta
« Reply #14 on: April 19, 2019, 10:27:51 pm »
So you want to change the value of the meta param before it's saved in the database? Or can you update it in the database later?

Regards.

i know how to update the database to change it with posted_item hook! i don't wanna use database to do this!
i want to replace the value of the meta param before it's saved in the database!