view only template

Status
Not open for further replies.

akirasrebirth

New Member
Hello

I'm using two different templates in a form, one for data submit and one for view only.
The view only template displays only elements with data.
I would change the order of the elements in the view only form without changing the order in the submit form.
Also a would that the tooltip displays only in submit form and not in the view only form ... is that possible?

Sorry for bad English :'(
Thanks Roland

This is the view only template code
Code:
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>
<?php echo $this->form->error;?>
<form class="fabrikForm" action="<?php echo $this->form->action;?>"
<?php echo $this->form->js;?> method="post"
    name="<?php echo $this->form->name;?>"
    enctype="<?php echo $this->form->encType;?>"><?php if($this->showEmail){
        echo $this->emailLink;
    }?> <?php if($this->showPDF){
        echo $this->pdfLink;
    }?> <?php if($this->showPrint){
        echo $this->printLink;
    }?>

    <?php foreach( $this->groups as $group ){?>
    <?php if($group->canRepeat){?>
        
    <?php }?>
    <div class="fb_group" id="group<?php echo $group->id;?>" style="<?php echo $group->css;?>">
        <table>
        <?php if($group->canRepeat){
            $subgroupCounter = 0;
            foreach($group->subgroups as $subgroup){
                if($group->canRepeat && $this->task != 'viewTableRowDetails' ){?>
                    <div><a class="addGroup" href="#" id="<?php echo $group->addId;?>"><?php echo _ADD;?></a> | <a class="deleteGroup" href="#" id="<?php echo $group->delId;?>"><?php echo _DELETE;?></a></div>
                <?php }?>
                <div class="fb_sub_group" id="subgroup<?php echo $group->id . "_" . $subgroupCounter;?>">
                <?php foreach( $subgroup as $element ){?>
                    <?php if($element->error != ''){?>
                        <tr class="fb_element" id="fb_element_<?php echo $element->int;?>">
                            <td colspan="2">
                            <div class="fabrikerror"><?php echo $element->error;?></div>
                            </td>
                        </tr>
                    <?php }?> 
                    <tr class="fb_element">
                        <td><?php echo $element->label;?></td>
                        <td><?php echo $element->element;?></td>
                    </tr>
                <?php }?>
                </div>
                <?php $subgroupCounter ++;
            } ?>
        <?php }else{?>
            <?php foreach( $group->elements as $element ){?>
                <?php if($element->error != ''){?>
                    <tr class="fb_element">
                        <td colspan="2">
                        <div class="fabrikerror"><?php echo $element->error;?></div>
                        </td>
                    </tr>
                <?php }?> 
                <?php if ($element->value) { ?>
                <tr class="fb_element" id="fb_element_<?php echo $element->int;?>">
                    <td><?php echo $element->label;?><td>
                    <td><?php echo $element->element;?></td>
                </tr>
                  <?php }?> 
            <?php }
         }?>
        </table>
    </div>
    <?php }?>
    
<?php echo $this->hiddenFields;
echo $this->ask_receipt?>
<div class="fabrikActions"><?php echo $this->form->resetButton;?> <?php echo $this->form->submitButton;?>
</div>
</form>
<?php echo $this->jsActions; ?>
 
hi

You will need to write out the elements one by one in your template to achieve this. Below is an example that I have just added to the SVN:

Code:
<?php /**
 * @package  fabrik
 * @version 1.0.5
 * @Copyright (C) Rob Clayburn
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * 
 * this is a simple example of how to write a custom form template
 */
/* MOS Intruder Alerts */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>


<!--  write out the form title, javascript and introduction text -->
<h1><?php echo $this->form->title;?></h1>
<?php echo $this->topJS;
echo $this->form->intro;?>


<!--  if the form has failed validation then write out the error message -->
<?php if( $this->form->error != '' ){
    echo "<div class='fabrikerror'>" . $this->form->error . "</div>";
}?>

<!--  ok lets start the form -->
<form action="<?php echo $this->form->action;?>" class="fabrikForm" <?php echo $this->form->js;?> method="post" name="<?php echo $this->form->name;?>" id="<?php echo $this->form->name;?>" enctype="<?php echo $this->form->encType;?>">
    
    
    <!--  here we are writing out some of the actions that can be performed -->
    <?php if($this->showEmail){
        echo $this->emailLink;
    }
    if($this->showPDF){
        echo $this->pdfLink;
    }
    if($this->showPrint){
        echo $this->printLink;
    }?> 
    
        <!--  uncomment (remove the '//') from the line below to see a list of all your elements -->
        <?php // echo "<pre>"; print_r($this->data); echo "</pre>"; ?>
        
        <!--
        for each of the elements you want to show in your custom layout
        copy and paste the following  lines (until the line '*** end elements ****'
        For each repetition replace 'quicktime___checkbox' in the line below with the name of the element you want to render
        For this example ('quicktime___checkbox') - 'quicktime' refers to the table name and 'checkbox' to the element name
        -->
        <?php $element = $this->data['quicktime___checkbox']; ?>
        
        <!-- contain the element within its own div -->
        <div class="<?php echo $element->divclass ?>"  id="fb_element_<?php echo $element->int;?>">
        
            <!--  if the element fails its validation then show the error -->
            <?php if($element->error != ''){?>
                <div class="fabrikerror"><?php echo $element->error;?></div>
            <?php }?>
            
            <!--  write out the label and element -->
            <?php echo $element->label;?> <?php echo $element->element;?>
        </div>
        
        <!--  *** end elements ****  -->

    <!--  write out the hidden fields and bottom form buttons -->
    <?php echo $this->hiddenFields;
    echo $this->ask_receipt; ?>
    <div class="fabrikActions">
        <?php echo $this->form->resetButton;?> 
        <?php echo $this->form->submitButton;?>
    </div>
    
    <!--  close the form -->
</form>
<?php echo $this->jsActions; ?>

<!--  this div is required if you are using the scroller navigation to scroll through records -->
<div id="fabrikScroller"></div>

You can't remove the hover text from the element labels, but you could simply not use the label and write it in by hand into the template. so for each element you add into the template replace:

Code:
<?php echo $element->label;?>

with the label you wish to use

hth
Rob
 
The workaround for the tooltip will not work for me because I'm using 3 languages on my site and the labels would not be translated.

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

Thank you.

Members online

Back
Top