1

I am very new to CakePHP and MySQL so I may not know how to properly ask this. I need to add a payment type radio button to a project I just inherited. I added the payment type radio button to the add and edit forms like this:

$options = array('check' => 'Check', 'credit' => 'Credit');
$attributes = array('legend' => false);
echo $this->Form->radio('payment', $options, $attributes);

The radio button shows up as expected but payment is not in the MySQL database so

<?php echo h($purchaseOrder['PurchaseOrder']['payment']); ?>

causes

Notice (8): Undefined index: payment [APP\View\PurchaseOrders\view.ctp, line 81]

What is the best way to add payment to the database? Is there a way to modify the database without losing existing records?

jacknad
  • 13,483
  • 40
  • 124
  • 194
  • Do you *want* to store the payment value? Or is it just a radio button used for changing form inputs and the like? – Nunser Apr 24 '13 at 15:50
  • I need to save it to the database with the record. It needs to be selected when adding or editing a record and displayed on other views. – jacknad Apr 24 '13 at 15:54

1 Answers1

2

This is primarily a MySQL question rather than CakePHP, if you are able to execute a MySQL Query I would try something like the following (change to your needs):

ALTER TABLE purchase_orders ADD COLUMN payment VARCHAR(6);

You may benefit from downloading a MySQL tool such as SQLYog or HeidiSQL. If you get the notice after you have added the payment column on a view for example you may want to check the 'fields' parameter on your query (if applicable)

HelloSpeakman
  • 810
  • 9
  • 22
  • The project was setup using PhpMyAdmin and a method to add the field is [here](http://stackoverflow.com/a/6260040/398460). Thanks a million. – jacknad Apr 24 '13 at 16:13