6 years ago
9
Topic

Hello,

I have two Fields in Form A:

Field Name: cr_account
Type: text
Storage: none

Field Name: cr_accountx
Type: FieldX
Field: cr_account
Storage: Custom | User | cr_accountx[cr_account]

In the database the content is stored in  table cck_store_item_users in column cr_accountx:

Example Storage:

<br />::cr_account::2::/cr_account::<br /><br />::cr_account|0|cr_accountx::Sunrise::/cr_account|0|cr_accountx::<br />::cr_account|1|cr_accountx::Sunset::/cr_account|1|cr_accountx::<br />

Now I want to use the Content (Sunrise | Sunset) of FieldX of the current logged in user in a Form B aus a Simple Drowpdown list.

How can I realize this?

Every advice ist welcome.

Papi

Get a VIP membership
1283 Posts
Bucklash
6 years ago
8
Level 1

Hi

Just to be safe....

  1. Field Name: cr_account 
  2. Type: text
  3. Storage: Custom | User | cr_accountx[cr_account]
  1. Field Name: cr_accountx
  2. Type: FieldX
  3. Storage: Custom | User | cr_accountx

Do not know about dropdown though :)

6 years ago
7
Level 2

Hi,

no, I mean this:

  1. Field Name: cr_account
  2. Type: text 
  3. Storage: none
  1. Field Name: cr_accountx
  2. Type: FieldX
  3. Field: cr_account
  4. Storage: Custom | User | cr_accountx[cr_account]
1283 Posts
Bucklash
6 years ago
6
Level 3

Hi

That is not the way recommended by Klas... 

6 years ago
5
Level 4

Hi Bucklash,

ah ok. I have followed this guide:

https://www.seblod.com/resources/tutorials/how-to-use-plugin-field-fieldx

Now it looks like:

  1. Field Name: cr_account
  2. Type: text
  3. Storage: Custom | User | cr_accountx[cr_account]
  1. Field Name: cr_accountx
  2. Type: FieldX
  3. Field: cr_account
  4. Storage: Custom | User | cr_accountx

Yeah, now the Search list ist working. Thanks!

Back to my initial question:

How can I use the fieldx as a Dropdown List in another Form?

1283 Posts
Bucklash
6 years ago
4
Level 5

Hi

Yeah, that is an out of date tutorial... 

I tried to find the forum post where I asked Klas these kind of questions, but didn’t find it.

Anyhow, I don’t know how to create a dropdown based on some fieldx values, I would probably update the my_dropdowm_field in db using afterstore (I’m an afterstore fanboy)

4229 Posts
Kadministrator
6 years ago
3
Level 6

That would require some custom coding, in form B you could add some empty Select field and render options manually using beforeRender event, but there is a problem - for security reasons dropdown field can only save values that are specified in the field configuration, so you would have to store this field's value to a hidden text field.

6 years ago
0
Level 7

Thanks for answering. I will give it a try.

6 years ago
1
Level 7

Ok, I have done some tests:

  • Adding Options to the Multiple Select Field is working. I have modified the options with the BeforeRender field.The Multiple Select Field is shown correctly in the Front-End and the User can select the options.
  • As you mentioned in your post, the values aren't stored.
  • Now I want to save the values that are selected from the user by using Before Store Field. But where can I find which options the user has selected? In which Object Property is this information saved?

Any hints are welcome.

Thanks for helping.

4229 Posts
Kadministrator
6 years ago
0
Level 8

If I remember correctly all posted values are available in $post (or similar named) variable, if not you can look at Jinput directly. Just take care you do proper filtering before storing data into database or malicious users will be able to hack you due to lack of validation.

Get a Book for SEBLOD