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']; ?>
</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']; ?>
</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'];} ?>
</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']; ?>
</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']; ?>
</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']; ?>
</dd>
</dl>
精彩评论