开发者

Hiding fields from view if table is empty and validating if not empty

开发者 https://www.devze.com 2023-03-23 17:11 出处:网络
Here is the scenario I am trying to work out a way to render specific data into a view based on additional user input.(I only want the specificand correspondingtags to render if there has been additio

Here is the scenario I am trying to work out a way to render specific data into a view based on additional user input. (I only want the specific and corresponding tags to render if there has been additional input received from the user)

And if the user开发者_运维知识库 has added more info, how would I go about validating the data? I thought about doing it simply based on if [education1] is not empty validate the corresponding [awarded1] and [graduation1] but for the life of me I cannot find a simple solution.

Thanks for your help in advance!

Here is the view (pretty standard baked view):

<dl><?php $i = 0; $class = ' class="altrow"';?>
                <h3 id="viewf">Education</h3>
        <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('University'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php echo $user['User']['education1']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Certification/Degree Awarded'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php echo $user['User']['awarded1']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Year of Graduation'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php if (!empty($user['User']['graduation1'])) { echo $user['User']['graduation1'];} ?>
            &nbsp;
        </dd>
                <br />
                <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('University'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php echo $user['User']['education2']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Certification/Degree Awarded'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php echo $user['User']['awarded2']; ?>
            &nbsp;
        </dd>
        <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Year of Graduation'); ?></dt>
        <dd<?php if ($i++ % 2 == 0) echo $class;?>>
            <?php echo $user['User']['graduation2']; ?>
            &nbsp;
        </dd>
</dl>
0

精彩评论

暂无评论...
验证码 换一张
取 消