9 years ago
5
Topic

Hi All,

Is it possible to setup a conditional state to assign the current user to a field?  I want to trigger that 'set' when another field changes.

I was thinking of using the 'Is Filled By' option but there doesn't seem to be anything on the page with the current user ID in it.

Thanks!

Get a VIP membership
9 years ago
1
Level 1

dr,

You could include a hidden field in your form (Button 1 - Label & Variation: Set Variation to "Hidden"), then set it's live value to the current user ID (Button 2 - Live + Live Value: Set Live to Joomla! User and configure Live Value as User = -Current- and Property = id). Then you can use the "Is Filled By" option in your conditional rule and reference this hidden field to get the current user ID.

There may be other more elegant ways to do it as well. But this is one way.

Good luck,

Denver

dr
9 years ago
0
Level 2

Thanks denverh, I tried that but couldn’t get it to work. Adding another hidden user field to the form caused a save error unless I gave it storage, and I didn’t want to do that.

I also tried bunch of other things, but essentially came to the conclusion that conditional states are really only useful for text / select fields and simple logic. Changing *to* a particular value is problematic for example, because of various side effects trying to do it with multiple conditions. Also the lack of load and submit events is limiting. Finally the date and user fields use multiple elements in the markup and these are not read or set properly by the conditional events for the cases I tested.

A related issue is this: http://www.seblod.com/resources/tracker/4813 making JS functionality pretty limiting overall.

If anyone else is interested this is what I ended up doing:

I wrote a javascript function for the page and setup all the events myself. There were a number of places to store this. Ideally, I’d like SEBLOD to provide a page scoped field for JavaScript and CSS for both content types and search lists. Unfortunately it does not. I’ve added a feature request here: https://github.com/Octopoos/SEBLOD/issues/36

In the end I stored it in the field definition itself, along with an onChange attribute in the same field definition to trigger it, and with code to detect if the related fields were on the page before taking any action. Note that the code in the JS field executes in the context of a document ready event, so you need to attach it to the window object for your onChange attribute to find it.

Regards,

-dr

9 years ago
1
Level 1

Hello dr,

for JS and CSS, there is this product

for conditional state, depending on your need, but in general, SEBLOD can answer to the most of need.

Effectively, in tab or every where else in hidden position, the validation will not work.

Sometime, instead of a big form with tab, perhaps it would be better to have simple form with multi stage.


Best regards.

Lionel

dr
9 years ago
0
Level 2

Hi Lionel,

It's hard to determine that product will work for me.  For one, it's not clear that

  • Add Code Before Render
  • Add Code CSS
  • Add Code JS

will work in a Search Form.  Can you confirm that they do?

Also, it says that

  • Add Code CSS
  • Add Code JS

Work in 'Any SEBLOD Views', so I assume they work in Item View.  But does

  • Add Code Before Render

work in ItemView?

Finally, there is a comment from a year ago questioning whether the store events work, and no one has addressed it.  It doesn't inspire confidence.  :( Has it been addressed?

Thanks,

-dr

9 years ago
0
Level 1

Hi dr,

yes CSS, JS, Beforerender will work in any view, and yes the 5 plugins here are all working well.


Best regards.

Lionel

Get a VIP membership