Forums

Hide unfilled fields in form

cesarvelame 16 Jan, 2013
How do I hide unfilled fields in a form?

I know this code <?php echo $form->data['data']; ?> shows the field, but i didn't have success in some PHP code to hide the field.

Can somebody help me?
GreyHead 16 Jan, 2013
Hi cesarvelame,

What exactly is the problem? What do you need to hide and where?

Bob
cesarvelame 16 Jan, 2013
I have the field "Motivo" unfilled and i need it hidden when is unfilled.

See this:
GreyHead 17 Jan, 2013
Hi cesarvelame,

OK, then you need to use PHP in the Email template. To do this you *must* have the Rich Text Editor turned off so that there is just a text area. Find the part of the template code that contains the <tr>. . .</tr> part for Motivo and change it like this:
<?php
if ( $form->data['Motivo'] ) {
?>
<tr>
 . . . 
</tr>
<?php
}
?>


Bob
cesarvelame 18 Jan, 2013
Thanks, but I would use this code in the form, not in the email.

I did this and it works:


<?php
if ( $form->data['motivo'] ) {
echo "<label>Motivo</label>{motivo}";
}
?>
GreyHead 19 Jan, 2013
Hi cesarverlame,

Yes, that will work.

But why do you need to hide parts of the form? Just curious, I don't think I've seen that request before.

Bob
cesarvelame 21 Jan, 2013
GreyHead, I did a small system with Chronoforms.

I have 4 forms:

Content Submission - fields name and content
Content Management - fields name, content, status (pending, rejected and published), link (when published) and motive (when rejected)
Content Status Query - field code (unique id gh)
Content Status View - fields name, status, link and motive ( both if filled by the admin)

People sends content and receives a code that they can query the status in any moment.

In the Status View form I wanted only to show the fields filled by the admin.

Did you understand? My english is crap, I´m sorry.
GreyHead 22 Jan, 2013
Hi motivo,

Yes that makes perfect sense, and yes the same kind of PHP will work in the form HTML too.

Bob
This topic is locked and no more replies can be posted.