Hide label if value is empty

Status
Not open for further replies.

piri314

Member
Another question :

How to make => In the DetailedViewForm : if the element has no value, the element and it's label are not shown ?

Thanks
Pirina
 
You'd have to clone your chosen tempplate to a custom template, and slightly modify the PHP to test for empty values and skip if no value.

If you aren't comfortable with PHP in the templates, get the process started by creating your custom template (see the How Do I forum for a quick description of how to do that), then follow up here and let us know which template you cloned. We'll give you the PHP pointers you need.

-- hugh
 
Hi Hugh,

I made some custom Tamplates for each master table of my site

Annuaire (Directory) > Form (based on mint) + Table "annuaire" (based on default)
Contacts > Form (based on mint) + Table "contacts" (based on default)
Projets (Projects) > Form (based on mint) + Table "projets" (based on default)
Programmes EU > Form (based on mint) + Table "programmes" (based on default)

In the DeatailedViewForm (but not in the AddForm) of which one I need to Hide label if the value is empty.

I'm a newbie with PHP.

Thanks for the help.

PIRINA
 
When you say "hide the label if the value is empty", do you actually mean simply skip showing that entire row of the form?

-- hugh
 
Hi Hugh,

Row=Item or just 1 element ?

For me (sorry to use pictures, but my english knowledge is not enough) if an element is empty, the line have to be skip (label and element).
In the picture, the last to elements are empty, so I would like the label (and line) is hide.



PIRINA
 

Attachments

  • exEmptyElements.gif
    exEmptyElements.gif
    23.5 KB · Views: 220
  • exEmptyElements.gif_thumb
    22.5 KB · Views: 221
OK. In which case, using 'default' as an example:

Code:
			<?php foreach( $group->elements as $element ){?>
				<div class="fb_element" id="fb_element_<?php echo $element->int;?>"><?php if($element->error != ''){?>
				<div class="fabrikerror"><?php echo $element->error;?></div>
				<?php }?>
                <?php if ($element->value) { ?>
                  <?php echo $element->label;?> <?php echo $element->element;?>
                <?php }?>
				</div>
			<?php }

My only worry about this is that it might confuse the form processing code if the content of the element isn't there. If it causes problems, let me know. We can always hide the div instead.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top