Forums

Only fields checked in the email

Marizu 15 Jun, 2009
Hi!
I have a question about chronoform.
Is it possible, to have in the email, only the fields that are checked in the form?
Because I receive the email with all the fields, even if empty.
Thanks in advice for your help!
Marizu 15 Jun, 2009
Please, no one can help me?
samoht 15 Jun, 2009
Yes, this is possible. You should post some of your form code and the email template so we can help better.
{fieldname} will include the value of that for field only if there is a value to include, but you have fieldname:{fieldname} in you email template then even if the form field is left empty the email will still have fieldname:

So, if we had a little more info about your set up we could help better
Max_admin 16 Jun, 2009
Hi Marizu,

please post an example for the problem and the result you would like to have!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Marizu 16 Jun, 2009
Thanks for your reply!

My form, for example is
name
lastname
address
telephone
do you like my site? Yes No (checkbox)
date of birth (field)

If a person don't check or fill a fields, the email arrived with the field empty

I would like the email arrived with only the fields are filled

Is it possible?

Many thanks!
Marizu 18 Jun, 2009

{fieldname} will include the value of that for field only if there is a value to include, but you have fieldname:{fieldname} in you email template then even if the form field is left empty the email will still have fieldname:



Sorry to disturb you, then is impossible having the fieldname in the email only if it is filled, right?

For example
name: {name} if the field is fill, I receive it in the email
if the field is empty, I receive nor the "name:" neither the "{name}"

Please, confirm, so I can search for another way for solving my problem

Many thanks!
GreyHead 18 Jun, 2009
Hi Marizu,

It's possible but you will need to re-write your Email template using PHP.

First turn off the Use HTML Editor option on the Email Setup Properties.

Then it will be something like this
<?php
if ( $posted['name'] ) {
  echo '<div>Name: {name}</div>';
}
if ( $posted['lastname'] ) {
  echo '<div>Name: {lastname}</div>';
}
. . .
?>
I haven't tested this but I think it should work OK, come back and ask if there are any problems.

Bob
Marizu 18 Jun, 2009
Hi Bob,
I will try it!
Thanks a lot!
Marizu 19 Jun, 2009

Hi Marizu,

It's possible but you will need to re-write your Email template using PHP.

First turn off the Use HTML Editor option on the Email Setup Properties.

Then it will be something like this

<?php
if ( $posted['name'] ) {
  echo '<div>Name: {name}</div>';
}
if ( $posted['lastname'] ) {
  echo '<div>Name: {lastname}</div>';
}
. . .
?>
I haven't tested this but I think it should work OK, come back and ask if there are any problems.

Bob




Sorry Bob, it doesn't work...
I write it in my email template, but the email that arrived, is empty
The code need any modifications? Unfortunately I don't know php very well...
Thanks for your help
samoht 19 Jun, 2009
Hi Marizu,

Bob's code was generic and should work as long as the filed names are correct.
For example I have a email template that checks which amount to show:

<?php
if($_POST['otheramount']){ ?>
<p>for this custom amount: ${otheramount}</p>
<?php }else{ ?>
<p>for the amount of: ${amount} <br>
<?php } ?>
<p>Total amount charged = ${totalamount}</p>

so if {otheramount} is blank it will not show up. In order for this to work I need an input that has an id="otheramount" and a name="otheramount" - that way when the form is processed there will be a $_POST['ohteramount'] in the array of $_POST. What this all means is you need to name your inputs what you want to test on. So PLEASE show us your Form code so we can help more specifically.

A -

Also, the Form wizard will automatically apply the name and id to inputs as defaults. - so the first input text field that you add via the wizard will have an id equal to "text_0" or something like that.
This topic is locked and no more replies can be posted.