Permalink
Browse files

FIX: Make CreditCardField use template

  • Loading branch information...
1 parent 6c94300 commit d79d50770c09010777977396746103d053404e64 Tom Densham committed Sep 30, 2013
Showing with 16 additions and 10 deletions.
  1. +10 −10 forms/CreditCardField.php
  2. +6 −0 templates/forms/CreditCardField.ss
View
@@ -16,16 +16,16 @@ public function Field($properties = array()) {
$parts = array_pad($parts, 4, "");
// TODO Mark as disabled/readonly
- $field = "<span id=\"{$this->name}_Holder\" class=\"creditCardField\">"
- . "<input autocomplete=\"off\" name=\"{$this->name}[0]\" value=\"$parts[0]\" maxlength=\"4\""
- . $this->getTabIndexHTML(0) . " /> - "
- . "<input autocomplete=\"off\" name=\"{$this->name}[1]\" value=\"$parts[1]\" maxlength=\"4\""
- . $this->getTabIndexHTML(1) . " /> - "
- . "<input autocomplete=\"off\" name=\"{$this->name}[2]\" value=\"$parts[2]\" maxlength=\"4\""
- . $this->getTabIndexHTML(2) . " /> - "
- . "<input autocomplete=\"off\" name=\"{$this->name}[3]\" value=\"$parts[3]\" maxlength=\"4\""
- . $this->getTabIndexHTML(3) . " /></span>";
- return $field;
+ $properties['ValueOne'] = $parts[0];
+ $properties['ValueTwo'] = $parts[1];
+ $properties['ValueThree'] = $parts[2];
+ $properties['ValueFour'] = $parts[3];
+ $properties['TabIndexOne'] = $this->getTabIndexHTML(0);
+ $properties['TabIndexTwo'] = $this->getTabIndexHTML(1);
+ $properties['TabIndexThree'] = $this->getTabIndexHTML(2);
+ $properties['TabIndexFour'] = $this->getTabIndexHTML(3);
+
+ return parent::Field($properties);
}
/**
@@ -0,0 +1,6 @@
+<span id="{$Name}_Holder" class="creditCardField">
+ <input autocomplete="off" name="{$Name}[0]" value="{$ValueOne}" maxlength="4" $TabIndexOne/> -
+ <input autocomplete="off" name="{$Name}[1]" value="{$ValueTwo}" maxlength="4" $TabIndexTwo/> -
+ <input autocomplete="off" name="{$Name}[2]" value="{$ValueThree}" maxlength="4" $TabIndexThree/> -
+ <input autocomplete="off" name="{$Name}[3]" value="{$ValueFour}" maxlength="4" $TabIndexFour/>
+</span>

0 comments on commit d79d507

Please sign in to comment.