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?
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)