9 years ago
8
Topic

Hello

I'm trying to use the before render field from code pack on a site form for event registration that sends an email to the user.

I assign new values to some of my fields in the site form, like:

$fields['gbr_workshop_anmeldung_ort']->value = $address;

where gbr_workshop_anmeldung_ort is a textarea.

But the new value is not being rendered in the form. I only see the label of the field, the value is empty.

If I do

echo $fields['gbr_workshop_anmeldung_ort']->value;

in the before render field code, the value gets displayed.

In the description of the Code Pack plugin it says:

If you assign this field on admin or site form this code will be executed before to render the form.

The code is being executed but the new values are not being rendered in the form.

Also the new value is not transferred to the email text placeholder #gbr_workshop_anmeldung_ort#.

How can I render the newly assigned value in the site form and email text?

Get a Book for SEBLOD
9 years ago
1
Level 1

To verify, I have made a clean J!2.5.2.22 install with Seblod 3.3.5 and Code Pack 1.0.2


In article site form I added a before render field with this code:

$fields['art_title']->value = "Test";<br>echo $fields['art_title']->value;

When I login to frontend and edit an article, the echo command renders "Test".

But the article title field still has the original value.

This proofs that before render plugin is not working correctly for site forms.

What can we do to fix this?

9 years ago
0
Level 2

Added this to the tracker

9 years ago
2
Level 1

Anyone, could we please get some feedback on this issue?

693 Posts
rpoy
9 years ago
1
Level 2

Hey Gerhard,

OK! I have duplicated your results. So there appears to be a bug.

But I think there is a work around. You can create a hidden field and then copy the value from that field using conditionals to a normal SEBLOD field.

Using the BeforeRender field, I created a hidden text field and set the value manually like:

$myField = '<input id="myID" type="hidden" maxlength="255" size="32" value="'.$user_value.'" name="myID">';

echo $myField;


Where $user_value is the variable that you want to get out of the BeforeRender Field.

I also created a "real" field in the normal SEBLOD way, which will contain the final result.

Then using conditionals, you can set the

States: is Filled By | myID | #form#

Triggers: any_required_field | is Filled

So when the required field is filled with a value, the conditional will copy the value from your hidden field to the Final result which you can include in your email.

Will that work?

regards,

Randy

9 years ago
0
Level 3

Hello Randy,

I tested your workaround on my clean J!2.5.22 test install and it is working.

Thank you

Gerhard

9 years ago
1
Level 1

Hello Randy,

thank you very much for looking into this and verifying it.

Do I have to set the value of the hidden field have to be an <input> field in order to also include it into the email?

Cheers

Gerhard

693 Posts
rpoy
9 years ago
0
Level 2

Hi Gerhard,

Yes! In my example, I used the variable $user_value to set the value of the hidden field. Looking at your original post, you were using the $address variable, so you could use that instead - or what ever you want. The 2 critical values to know is the name/id of the hidden field and the variable for the value. In my test, I was not able to include the hidden name (myID) in the email, which is why I copied the hidden field to another SEBLOD field using conditionals.

Hope that helps,

Randy

9 years ago
0
Level 1

Saba has replied to the tracker issue with some very helpful information.

To manipulate the value of form inputs on site forms, we have to use different code than in site content:

>> When a form is rendered by the core, the property used is not ->value but ->form.
That means that if you alter ->value during the beforeRender event, you'll need to use $cck->getValue('art_title') later.
Obviously that's not what you want...

So.. you should try to construct the form input like that:
$fields['art_title']->form = '< input .............. value="Hey" / >';
or to replace the old value by your new one:
$new = 'value="Hey"';
$old = 'value="'.$fields['art_title']->value.'"';
$fields['art_title']->form = str_replace( $old, $new, $fields['art_title']->form );

Hopefully, one day this will be part of an official Seblod documentation. At least this info should go in the description of the Code Pack plugin.

Get a VIP membership