Skip to content

Commit

Permalink
Merge pull request silverstripe#2468 from nedmas/make-creditcardfield…
Browse files Browse the repository at this point in the history
…-use-template

FIX: Make CreditCardField use template
  • Loading branch information
chillu committed Oct 3, 2013
2 parents 5067a3d + d79d507 commit bb7c973
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 10 additions & 10 deletions forms/CreditCardField.php
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions templates/forms/CreditCardField.ss
@@ -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 bb7c973

Please sign in to comment.