6 years ago
3
Topic

Hello,

I want to strip_tags from a field (cr_account_name) in GroupX fields with the Plugin Before Store.

GroupX field:
cr_accounts_grpx

Fields in GroupX:
cr_account_name
cr_account_id

My Code:

$grpx = $fields['cr_accounts_grpx']->values;


$i=0;
foreach($grpx as $gx) {

$gx['cr_account_name'] = strip_tags($gx['cr_account_name']);
$fields['cr_accounts_grpx']->values[$i] = $gx;

$name = $fields['cr_accounts_grpx']->storage_field;
$table = $fields['cr_accounts_grpx']->storage_table;
$config['storages'][$table][$name] = strip_tags($gx['cr_account_name']);

$i++;
}

A Var Dump from $fields before this Code shows me for cr_accounts_grpx->values:

A Var Dump from $fields after this Code shows me for cr_accounts_grpx->values:

The Var Dump of $name:
cr_accounts_grpx

The Var Dump of $table:
#__cck_store_item_users

So, the strip_tags is working and the Object and the Array are filled correctly. The column cr_accounts_grpx seems ok and #__cck_store_item_users is the table where cr_accounts_grpx is stored.

But after saving the fields from GroupX are empty.

What i'm doing wrong?

Thanks for helping

Papi

Get a Book for SEBLOD
4229 Posts
Kadministrator
6 years ago
1
Level 1

I would say problem is in $config['storages'][$table][$name] = strip_tags($gx['cr_account_name']); -  with group X all data is stored in parent so you need to modify parent storage, not children. dump $config to see what is inside before, it is either an array, the same as with fields, or a large encoded string.

6 years ago
0
Level 2

Hello Klas,

thanks for helping me.

Before my code, the $config looks like this:

The field cr_accounts_grpx contains the exactly string with all child fields information.

After my code, the $config looks like this:

The field cr_accounts_grpx contains only the raw data of the first child field cr_account_name. 

Ok, I understand that I must fill the field cr_accounts_grpx with the whole large string. But how can I realize this?

How can I put back the strip tagged field cr_account_name back to the cr_accounts_grpx field? Is there anywhere out there an example for this?

Papi

4229 Posts
Kadministrator
6 years ago
0
Level 1

libraries/cck/content/content.php has few functions that can help with that

Get a Book for SEBLOD