This site uses cookies and similar technologies.

If you don't change browser settings, you agree to it.

I understand
153 Posts
redback
4 years ago
Topic

Hello,

i not quite sure about the BeforeStore plugin.

Approach: Wonna change a value of normal field. The changed value should saved in the database.

Set-Up: on SiteForm

My Try:

$fields['myfield']->value = "Try to change the value of myfield";

Any idea how to achieve this?

Get a VIP membership
153 Posts
redback
4 years ago
0
Level 1

Well i have the answer. Got it out of  this threat. Here an explanation

How you change field values with BeforeStore Plugin

Generell Info

  • It is necessary that you can read php arrays. 
  • $config (features)
    • Is an multidimensional array
    • Contains the values who are gonna saved
    • You need to address your value within this array 
  • You are able to call field values with $fields['myfield']->value
  • You can you use joomla classes

Step by Step

  1. Find out how to address your value within the $config
    Tipp: Use var_dump($config);die();) within your BeforeStore field, to have an look to the array. Switch in your Browser to the source code view.
  2. If your field has the name "myfieldname", there could be come out something like this, to address your field value
    $config['storages']["#__cck_store_form_mycontentview"]["myfieldname"]
  3. Make the manipulation / change of your field value
// Example 1 - Just Text

$config["storages"]["#__cck_store_form_mycontentview"]["myfieldname"] = "I changed the value of myfieldname with BeforeRender";
// Example 2 - Get the value of another field

$config['storages']["#__cck_store_form_mycontentview"]["myfieldname"] = $fields["anotherfieldname"]->value;

// This works on unsaved values of "anotherfieldname" - Its means you just typed it in the SiteForm
Get a VIP membership