Skip to content

Instantly share code, notes, and snippets.

@taleeb35
Created December 18, 2014 07:13
Show Gist options
  • Save taleeb35/c0b4eb32e7db0096c44f to your computer and use it in GitHub Desktop.
Save taleeb35/c0b4eb32e7db0096c44f to your computer and use it in GitHub Desktop.
<div class="controls form">
<?php echo $this->Form->create('Control'); ?>
<?php $days = array(1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday", 7 => "Sunday"); ?>
<?php $month_days = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13,
14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, 21 => 21, 22 => 22, 23 => 23, 24 => 24,
25 => 25, 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30, 31 => 31); ?>
<fieldset>
<legend><?php echo __('Add Control'); ?></legend>
<?php
echo $this->Form->input('name',array('label' => 'Task Title'));
echo $this->Form->input('description',array('label' => 'Task Description'));
echo $this->Ck->load('Control.description');
echo $this->Form->input('associated_standards');
echo $this->Ck->load('Control.AssociatedStandards');
echo $this->Form->input('control_frequency_id', array('id' => 'frequency')); ?>
<div id="weekly" style="margin-left: -10px;">
<?php echo $this->Form->input('day_of_week',array('type' => 'select','options' => $days)); ?>
</div>
<div id="monthly" style="margin-left: -10px;">
<?php echo $this->Form->input('day_of_month',array('type' => 'select', 'options' => $month_days)); ?>
</div>
<?php echo $this->Form->input('owner_id'); ?>
<?php //echo $this->Form->input('risk_level_id'); ?>
</fieldset>
<?php echo $this->Form->end(__('Submit'));?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul>
<li><?php echo $this->Html->link(__('List Controls'), array('action' => 'index'));?></li>
</ul>
</div>
<script type="text/javascript">
// $('#weekly,#monthly').hide();
$('#frequency').change(function(){
var selection = $("option:selected", this).text();
switch(selection) {
case 'Weekly':
$('#weekly').show();
$('#monthly').hide();
$('#monthly').disable();
break;
case 'Monthly':
$('#monthly').show();
$('#weekly').hide();
$('#weekly').disable();
break;
default:
$('#weekly,#monthly').hide();
break;
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment