1

I'm setting up a Stripe payment form, so I need to remove the names of my month and year fields so they aren't sent to my server. The following code though, still gives the field a name of '[month]' and if the text of the array's name variable were 'xyz', the field would be named 'xyz[month]'. How can I remove the entirety of the field's name?

echo $this->Form->month('expiration_month', array('name' => '', 'data-stripe' => 'exp_month', 'default' => 'January'));
thekthuser
  • 706
  • 1
  • 12
  • 28
  • Unset ```$this->request->data['expiration_month]``` before calling Stripe api http://php.net/manual/en/function.unset.php – Salines May 24 '16 at 07:39

2 Answers2

1

According to the documentation, the name of the <select> element is derived from the first function argument ("expiration_month" in your example.) If you take a look at the code, you can see the value "month" is hard-coded.

The only way around this is to manually build your own <select> element, or just ignore the value when it comes to your server. But why make users fill out a form element that isn't going to be processed by your server?

miken32
  • 42,008
  • 16
  • 111
  • 154
  • 1
    It isn't going to my server because it's being sent directly to Stripe. This way you don't have to worry about PCI compliance on credit card data. – thekthuser May 23 '16 at 23:37
  • But if you aren't sending a `name` attribute, it won't be processed by *any* server because it won't get sent by the browser. – miken32 May 30 '16 at 18:37
-1

So, the quick and dirty way around this is to find the select field with js and overwrite the name attribute.

thekthuser
  • 706
  • 1
  • 12
  • 28