View Single Post
Old 08-18-2015, 11:42 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline

Join Date: Dec 2010
Posts: 6,373

Default Re: form getDefaultParams is not working

Originally Posted by Roman Prisiazniuk
when I submit form it does not insert date field to sql query, it just uses null, and I get this error
An exception occurred while executing 'INSERT INTO xc_order_item_activations (order_item_id, date, credit, activation_code, ip_address) VALUES (?, ?, ?, ?, ?)' with params [null, null, "2", null, null]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'date' cannot be null

This is because your $schemaDefault describes the "credit" field only, so X-Cart uses "null" value for the rest of the entity fields.

You may try to set the missing properties in the View\Model\OrderItemActivation ::setModelProperties() method.

Originally Posted by Roman Prisiazniuk
Also tell me please next:
I added multiple forms(as above) on my order page, every order item has its own form, how can I add hidden field to this form that must have valu of order_item_id?

You can add hidden fields to a form by declaring them in the getDefaultParams() method of your form class that extends \XLite\View\Form\AForm.

For example, check the \XLite\View\Form\Profile class.
Alex Solovev,


User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote