548 Posts
joomleb
7 years ago
9
Topic

Hi guys,

About Computation Rules

Adding a Concatenate rule, Please, How to add a space into two fields ? Where my filed should be "FieldA FieldB" and not "FieldAFieldB"

and, Please, What does "Rule Global" / "Rule Self" mean in Computation Rules setting ?

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

Concenate merges 2 strings without space, you can use Custom for your need.

548 Posts
joomleb
7 years ago
4
Level 1

Hi Klas, thanks for reply:


1 - Computation Rules: Custom > Free: ...?!?...

During the night I tested a lot of inputs like: a + " " + b / a & " " & b / ...and so on, but none seem to work. Please, Can you suggest me any input just for add a space between "a" field and "b" field ?

PS Logically before to ask I looked for here and the only thing I found is this foryears old "Using computation rules? concatenate" unsolved post


2 - and, Please, What does "Rule Global" / "Rule Self" mean in Computation Rules setting ?

Thanks for help

4229 Posts
Kadministrator
7 years ago
3
Level 2

I tried to make custom work with coencenate without success, but I foud a workaround - add a text field without storage with default value set to " " and add it to the fields that get coancenated. According to the manual fields are used in the alphabetic order, so be carefull how you name it.

548 Posts
joomleb
7 years ago
2
Level 3

Hi Klas,

many thanks for the suggestion, I tested it and:

1 - I'm not able to set default value as " ", with " or without it seem that Seblod delete (not consider) the space. So for example, if I input " - " in the Text field, the result is "-" when concateneted. Please, Can you confirm it ? Do you have any suggestions ?

2 - despite you can orders the fields into the Computation Rules setting, Concatenate does not follow that order and seem to follow the order position into the User Content Type Form - Admin. Please, Can you confirm it ? Is it right or is it a "bug" ?

4229 Posts
Kadministrator
7 years ago
1
Level 4

You can try inserting & n b s p ; (without spaces) - html code known as nonbreaking space. Acoording to manual order is defined by the alphabetical order of the field names.

548 Posts
joomleb
7 years ago
0
Level 5

Hi Klas,

I made a lot of tests and:

1 - "try inserting a nonbreaking space "& n b s p ;" (without spaces)" = Input it as default value field, it is saved as a space in the field, but it is not considered (like does not exist) for the Concatenate Computation Rule.

PS Adding "- -" or "d d" the space between the two letters is saved and respected/considered, while saving " ", or "p ", or " p" the space is not considered, like does not exist.

Really I think that should exist a way to add a "virtal space" using Concatenate Computation Rule, Don't you think ?

2 - "According to manual order is defined by the alphabetical order of the field names" = Yes, I red the Manual: "Each field selected is referred to in alphabetical order, i.e. the first field is referred to as "a", the second as "b", the third as "c", and so on", but doesn't running in that way for the Concatenate Computation, does not follow that order and neither does not follow the alphabetical order of the field names. Tested again and I can confirm you that seem to follow the order position into the User Form & Content Type - Admin Form. Please, Can you confirm it ? I suppose it is a "bug", right ?

3 - Please, What does "Rule Global" / "Rule Self" mean in Computation Rules setting ?

Thanks for help

1283 Posts
Bucklash
7 years ago
2
Level 1
548 Posts
joomleb
7 years ago
1
Level 2

Hi Bucklash,

I'm not a programmer, but I red all the guides and setting a BeforeStore Mode free code should be something like this:

$usrFirstName = $fields['user_first_name']
$usrLastName = $fields['user_last_name']

$config['storages']['#_users']['name'] = $usrFirstName . ' ' . $usrLastName;

Am I right ?

And using the BeforeStore processing I can set "Name" joomla field to the "hidden" variation so it is not visible nor manipulable by the user in the source code, right ?

1283 Posts
Bucklash
7 years ago
0
Level 3

Hi

If it is in the source code it can be manipulated.... hidden or not hidden.

Anyway: Below shows the use of  ‘value’ but you might want to do var_dump($fields); using beforerender field to see what else you can use (maybe not for current example, but in other situations)

$usrFirstName = $fields['user_first_name']->value;
$usrLastName = $fields['user_last_name']->value

$config['storages']['#_users']['name'] = $usrFirstName . ' ' . $usrLastName;

Get a Book for SEBLOD