FIX: Make CreditCardField use template

This commit is contained in:
Tom Densham 2013-09-30 16:48:15 +01:00
parent 6c943007a1
commit d79d50770c
2 changed files with 16 additions and 10 deletions

View File

@ -16,16 +16,16 @@ class CreditCardField extends TextField {
$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);
}
/**

View File

@ -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>