Forums

Conditional If then in "Edit" code of "Admin list"

ErixSr 27 Dec, 2018
Good evening to all and best wishes.
I'm working with ChronoForms5 and ChronoConnectivity5 and I can not solve a problem (maybe it will be stupid and I do not even see it). With a form, customers send me data. Besides their address they can send me another address for shipping. With the conditional system you open the "shipping address" form, if the customer selects "No" ok, in case of "Si" the mask does not open. (

So far everything is ok. The form arrives via email quietly and works well. Now I've connected ChronoConnectivity5 and I'm compiling the code to "edit" the data.
In "Admin List" / "Actions" / "Edit" ----
Code I entered the following:

<?php if ($form->data['spedizione'] == "Si"): ?><table width="80%" border="1" style="border-collapse: collapse;"><tr><td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è lo stesso</font></b></td></tr></table><?php else: ?><table width="80%" border="1" style="border-collapse: collapse;"><tr><td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è:</font></b></td></tr><tr><td><b>Nome e Cognome:</b>&nbsp;{nomesp}&nbsp;{cognomesp}</td><td><b>Ind.:</b>&nbsp;{indirizzosp},&nbsp;{civicosp}</td></tr>....</table><?php endif ?>
But by checking the conditional does not work.
Where am I wrong?

Thank you.
ErixSr 17 Jan, 2019
no news for me?
healyhatman 17 Jan, 2019
If you're creating from scratch, do it in v6
ErixSr 18 Jan, 2019
the trouble is that I have the form in CF5. transferring them to CF5 is a big job ...
can I use CCv6 with CF5?
healyhatman 18 Jan, 2019
unless you need to have the CC connection INSIDE the form, there's no reason you can't use CCv6 to get the data saved to the database by a CFv5 form.
ErixSr 18 Jan, 2019
OK thank you.
With CCv6 I can perform the operation conditional that in CCv5 drives me crazy?
healyhatman 18 Jan, 2019
You can do whatever you want. What exactly is it you're trying to do?
ErixSr 18 Jan, 2019
in the Admin List / Action / Edit, I report the data of a form. The problem arises when I try to make the shipment address data visible / invisible. That is, if the customer answers "Yes" it means that the address already written in his data is the same to be used for shipping. If you answer "No" the data of the new address should appear. Using the PHP reported in the 1st post I can not get anything.
healyhatman 18 Jan, 2019
Oh yeah that would be easy to do
ErixSr 18 Jan, 2019
The data Yes / No is present, when I insert the input field to be modified, it appears
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />
ErixSr 18 Jan, 2019
then you confirm that in CCv5 can not be done?
healyhatman 18 Jan, 2019
Never used CCv5 it can probably be done but I can't help you with it
ErixSr 18 Jan, 2019
Ok, thank you, I try to use CCv6 with CFv5, hoping it works ...
ErixSr 22 Jan, 2019
In CCv there are few tutorials and for those not in the trade everything gets complicated. Is nobody there to help me with the initial problem? It seems to me there is little assistance ... some time ago I had already validated CFv5, but now I do not know if it's worth to validate the rest ...
healyhatman 22 Jan, 2019
OK well when you said at the start that "the conditional does not work" what do you mean? What IS shown, and what is supposed to show instead?

And there are FAQs and demo connections. The problem isn't lack of documentation so much, it's that it's complicated.
ErixSr 22 Jan, 2019
You're right, but I think that a solution to my initial question there is no need to resort to CCv6 that is making me more confused. I do not have a lot of knowledge and I was beginning to become familiar with CCv5. I tried what I know and it does not work. Could it be that there is not someone who can solve this small problem?
healyhatman 22 Jan, 2019
We can try to solve it together if you answer my question🙂

OK well when you said at the start that "the conditional does not work" what do you mean? What IS shown, and what is supposed to show instead?

ErixSr 23 Jan, 2019
I thank you for your patience and I hope to be clear.
In "Admin List - Actions - Edit" I open the edit window (cattura001) and up to here everything is fine. When I report the data there is a conditional question that comes from CFv5 "Cattura spedizione uguale?" and the data, as you can see, arrives exactly.
If the answer, if "No" should appear the window you see in capture002, otherwise the window does not appear.
I was thinking of solving with
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />

<br />
<?php
if ($Calessini.spedizione == "Si"):
?>
<table width="50%" border="1" style="border-collapse: collapse;">
<tr>
<td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è lo stesso</font></b>
</td></tr>
</table>
<?php else: ?>
<table width="50%" border="1" style="border-collapse: collapse;">
<tr>
<td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è:</font></b>
</td></tr>
<tr>
<td width="50%"><b>Nome e Cognome:</b>&nbsp;{Calessini.nomesp}&nbsp;{Calessini.cognomesp}</td>
<td width="50%"><b>Ind.:</b>&nbsp;{Calessini.indirizzosp},&nbsp;{Calessini.civicosp}</td></tr>
<tr><td width="50%"><b>Cap:&nbsp;</b>&nbsp;{Calessini.capsp}</td>
<td width="50%"><b>Città:</b>&nbsp;{Calessini.cittasp}</td></tr>
<tr><td width="50%"><b>Prov.:</b>&nbsp;{Calessini.provinciasp}</td>
<td width="50%"><b>Telefono:</b>&nbsp;{Calessini.telefonosp}</td></tr>
<tr>
<td width="50%"><b>Email:</b>&nbsp;{Calessini.emailsp}</td><td></td></tr>

</table>
<?php endif ?>
But this does not work. I am convinced that this is a stupid mistake ... and yet I do it! :-(
Thanks for your patience
healyhatman 23 Jan, 2019
Instead of "Si" and "no" you should set your dropdown to send the VALUES 0 and 1, and show the LABELS "Si" and "no". Then you can just do
if ($Calessini.spedizione)

Also, just before that conditional, can you echo the value of $Calessini.spedizione to make sure it has the value you're expecting it to?
ErixSr 23 Jan, 2019
If I understand, when I change the yes / no with 0/1 I should then be able to see the data with:[pre]
<label> Indirizzo spedizione uguale? </ label> <input type = "text" class = "input-mini" style = "font-weight: bold" name = "Calessini [spedizione]" /> <br />[/pre]
Then the conditional:
<?php if ($Calessini.spedizione == 0): ?>
should work ...

Today I try and let you know.[br]Thanks for now.
healyhatman 23 Jan, 2019
You don't need to do if xxx == 0.

0 equates to false, 1 equates to true. So
<?php if ($Calessini.spedizione): ?>
Is the same as
<?php if ($Calessini.spedizione == true): ?>

is the same as
<?php if ($Calessini.spedizione == '1'): ?>

So on and so forth.

http://php.net/manual/en/types.comparisons.php
ErixSr 23 Jan, 2019
Even with true / false it does not work
begin to have a doubt.
When I recall the data with:
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />
the data is reported as "0" or "1"

When I insert it between the <? Php tags it does not work.
Can this be the problem?
<?php if ($Calessini[spedizione] ==  '1'): ?>
healyhatman 23 Jan, 2019
Shouldnt it be $form->data["field"] ?
ErixSr 23 Jan, 2019
Now I'm in confusion and full of doubts :-((
$ form-> data ["field"]
it is not the same as:
$ form->Calessini ["spedizione"] =
$ form-> ModelTitle["field"]

form is the name of the form in CFv5 ??? or... 😶
ErixSr 23 Jan, 2019
I'm trying to print on screen
<?php  echo $form->Calessini["spedizione"]; ?>
but no result...

if I avoid the Php ... it works
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />
healyhatman 23 Jan, 2019
What about $form->data["spedizione"]
healyhatman 23 Jan, 2019
Or $form->data["Calessini"]["spedizione"]
ErixSr 24 Jan, 2019
Nothing. It seems that the data
"Calessini[spedizione]"
<input type = "text" name = "Calessini[spedizione]" />

appears in HTML but not in PHP ...
GreyHead 24 Jan, 2019
Hi ErixSr,

The format is the last one that healyhatman posted
<?php echo $form->data['Calessini']['spedizione']; ?>
Adding a debugger action will show you the names and values of the form data.

Bob
ErixSr 24 Jan, 2019
Hi GreyHead,
I tried
<?php echo $form->data['Calessini']['spedizione']; ?>
but I did not have any answer.

Not having complete knowledge of CCv5, could you tell me where to insert the debugger action?
Thank you
GreyHead 25 Jan, 2019
Hi ErixSr,

Just to be clear is this ChronoForms v5 or ChronoConnectivity v5? There isn't normally form data in CC.

In CCv5 there is a Display Debug option near the bottom of the Front List > Settings tab.

Bob
healyhatman 25 Jan, 2019
I still highly recommend giving up and learning V6. You're already struggling, might as well struggle towards the current version.
ErixSr 25 Jan, 2019
Hi Bob,
summary the work:
1) I have prepared the form in ChronoForms5 and it works perfectly. the form arrives both to me and in copy to the client.
2) always in CFv5 I created the table (amod_calessini) that records every form sent.
3) With ChronoConnectivity5 I interrupt the table (amod_calessini) and all the data are reported.
At the moment I'm working in "Admin List" -> action -> Edit;
I created a linkable voice that gives me the opportunity to see all the details of that Id and possibly modify it.

The problem arises when I have to perform conditional If / then:
If shipping address is Equal then "same address"
"else" "the shipping address is:" etc.

If I report in the CC5 the result of the radiobox in CF5 this is reported quietly
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />



By entering in PHP
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" /><br />

<?php if ($form->data['Calessini']['spedizione'] == '1'): ?>
<table width="50%" border="1" style="border-collapse: collapse;">
<tr>
<td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è lo stesso</font></b>
</td></tr>
</table>
<?php else: ?>
<table width="50%" border="1" style="border-collapse: collapse;">
<tr>
<td colspan="2" align="center"><b><font style="color:red;">L'indirizzo di spedizione è:</font></b>
</td></tr>
<tr>
<td width="50%"><b>Nome e Cognome:</b>&nbsp;{Calessini.nomesp}&nbsp;{Calessini.cognomesp}</td>
<td width="50%"><b>Ind.:</b>&nbsp;{Calessini.indirizzosp},&nbsp;{Calessini.civicosp}</td></tr>
<tr><td width="50%"><b>Cap:&nbsp;</b>&nbsp;{Calessini.capsp}</td>
<td width="50%"><b>Città:</b>&nbsp;{Calessini.cittasp}</td></tr>
<tr><td width="50%"><b>Prov.:</b>&nbsp;{Calessini.provinciasp}</td>
<td width="50%"><b>Telefono:</b>&nbsp;{Calessini.telefonosp}</td></tr>
<tr>
<td width="50%"><b>Email:</b>&nbsp;{Calessini.emailsp}</td><td></td></tr>

</table>
<?php endif ?>
Warning, the code after else is the result of attempts so it can be wrong
ErixSr 25 Jan, 2019
Hi healyhatman,

I take your advice, it's right to work on a current product. The point, as I told you in another post is that I have always worked with 5, the form is already online and works. I wanted to complete the project with 5 and then devote myself more calmly to learning the 6 .... that's all.
ErixSr 26 Jan, 2019
Hi Bob,
sorry but I had forgotten the debugger from this result



the data arrives but is not processed in Php
healyhatman 26 Jan, 2019
So you told us repeatedly it's from a form but it's really a data read?
ErixSr 26 Jan, 2019
The conditional choice if then exists in the form. That is yes / no. The data, stored in the db, table "amod_calessini" is read by CConnectivity. In fact, he reports it correctly. The problem is when CC has to process that data in php, to make the other fields appear
ErixSr 26 Jan, 2019
I explained myself badly from the beginning ...
I did not explain that with CC I manage all the forms that arrive.
in these forms it is expected to insert a different address of the sender for the shipment. If this other address does not exist, I would like the corresponding fields not to appear. That's why I would like to get this result also in CC with Php (if then) and the given calessini.spedizione coming from the form.
I hope I have been clear and thank you for your patience
ErixSr 26 Jan, 2019
as I said, this is the data that appears in CC5 when it reads the data from the table "amod_calessini". This data can be "Si" (Yes) or "No" (No) and on this choice the conditional in php should work. And this does not
healyhatman 26 Jan, 2019
Answer
It would be SO much easier in v6. It would just be a switch, in the table column view you would put {fn:switch_name}. In the switch, you would put data source {var:table_view_name.row.model.calessini}, and your options would be 1:blahblah and 0:otherblahblah. Done.

But whatever. Let's keep trying.

Where are you putting this PHP code? Have you tried putting it in "PHP functions", as something along the lines of
model.field:if($row['model']['field'] == 1) return "HTML THAT I WANT"; else return "SOME OTHER HTML CODE";
ErixSr 28 Jan, 2019
A question: if I enter
<label> Indirizzo spedizione uguale?</label><input type="text" class="input-mini" style="font-weight: bold" name="Calessini[spedizione]" />
The result of the variable will be returned
"Calessini[spedizione]"

Why if I insert the request among the php tags the same is not returned?
<?php echo $Calessini[spedizione];?>
healyhatman 28 Jan, 2019
Because that's just not how it works. You've been given the syntax.
Where are you putting this code?
ErixSr 28 Jan, 2019
Hi healyhatman,
I finally solved thanks to the syntax you gave me.
The error was in comparing If with "Yes" instead of with 1 or 0.
Unfortunately, when you do not have a good preparation like me and little time to study you make ugly figures like I did. ...

Thanks and see you soon .... 🤗😶
healyhatman 07 Feb, 2019
Please mark the relevant post as the answer please🙂
This topic is locked and no more replies can be posted.