1283 Posts
Bucklash
8 years ago
0
Topic

Hi folks

This is a quick example/guide for using the Before Render plugin/field.
This is a hardcore field that truly makes Seblod great. I believe you can achieve the same functionality with the Code 42 field, but I'm happy using this.
The example here is taking some values form a form's fields and populating another value within the form with these values.
You can do this with Computation Rules but I wanted to concat two values, separated by '-'.
Five fields in total for this example (type : name)
{" text" : "title", "text" : "user_id", "text" : "cat_id", "beforerender" : "concat_stuff", "button" : "submit"}
I want the "title" field to be formed like this: "user_id-cat_id", note the hyphen (-) separating the two values.
The trick to populating form values is to use the word form rather than value and [square] brackets rather than (parenthesis) brackets (using a beforerender field, with the code "print_r($fields) and die;" allows you to see the variables available).The code I used in the beforerender field is this:
$fields['title']->form = $fields['user_id']->value . '-' . $fields['cat_id']->value;
	
PS: Thanks to Gebeer for asking the questions and Seblod for the replies that helped me get the answer :)

Bucklash

Get a Book for SEBLOD