function testTrimZeros() { $go = function ($a) { return Currency\trimZeros($a); }; assertEqual('2', $go(2.0)); assertEqual('2', $go('2.00000')); assertEqual('72.55', $go(72.55)); assertEqual('200', $go(200)); assertEqual('7500', $go('007500')); }
function contentForThisStep() { ?> <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#widget-end-date').datepicker({ dateFormat: 'yy-mm-dd', minDate: +1 }); }); </script> <?php echo $this->javascriptValidation(1); ?> <div id="step-1"> <h3>Step 1: Basic Information</h3> <?php if ($this->form && $this->form->hasErrors()) { ?> <?php foreach ($this->form->getErrors() as $e) { ?> <div class="alert alert-error"><?php echo $e; ?> </div> <?php } ?> <?php } ?> <br /> <div class="row-fluid"> <div class="span6" style="width: 100%;"> <div class="control-group"> <label class="control-label" for="widget-title">Title of Widget</label> <div class="controls"> <input type="text" class="input-large" id="widget-title" name="title" maxlength="30" value="<?php echo htmlspecialchars($this->widget->title); ?> " /> <span class="help-inline error-msg">Please provide a title.</span> </div> </div> <div class="control-group" id="widget-goal"> <label class="control-label" for="widget-want-to-raise">Amount to Raise</label> <div class="controls"> <?php $goal = isset($this->widget->goalAmnt) ? Currency\trimZeros($this->widget->goalAmnt->numUnits) : ""; ?> <input type="text" class="input-small" id="widget-want-to-raise" name="goal" value="<?php echo $goal; ?> "/> <?php $s = new SelectField('currency', 'Currency', array('USD' => 'USD', 'EUR' => 'EUR', 'GBP' => 'GBP', 'CNY' => 'CNY', 'CAD' => 'CAD', 'JPY' => 'JPY', 'BTC' => 'BTC')); $s->setID('currency')->setAttribute('style', 'width: 6em;'); $s->setValue(empty($this->widget->currency) ? 'USD' : $this->widget->currency); ?> <?php echo $s->renderInputHtml(); ?> <span class="help-inline error-msg">Please enter a valid (numeric) amount.</span> </div> </div> <div class="control-group"> <label class="control-label" for="widget-end-date">End Date</label> <div class="controls"> <input type="text" class="input-small" id="widget-end-date" name="ending" value="<?php echo $this->widget->endingDateAsString(); ?> "/> <span class="help-inline error-msg">Please correct the error.</span> </div> </div> <div class="control-group" id="bitcoin-addr-control-group"> <label class="control-label" for="widget-bitcoin-address">Bitcoin Address</label> <div class="controls"> <input type="text" class="input-large bitcoin-address" id="widget-bitcoin-address" name="bitcoinAddress" value="<?php echo $this->widget->bitcoinAddress; ?> " /> <span class="help-inline error-msg">Please provide a valid Bitcoin address.</span> <span class="help-inline not-error"> Please use a new, dedicated Bitcoin address for each widget. In this way, we are able to measure the amount that has been donated to your cause.</span> </div> </div> </div> <!-- /span6 --> <div class="span5 offset1"> <!-- <div class="well"> </div> --> </div> <!-- /span5 --> </div> <!-- /row-fluid --> </div> <!-- /step-1 --> <?php }