0

i have a form it's like assign a product through frontend. but my doubt is after that how i validate

<form action="<?php echo $this->getUrl('mpassignproduct/index/edit') ?>" enctype="multipart/form-data" method="post" id="form-customer-product-edit">

<li class="fields">
<div class="customer-name">
<div class="field">
<label class="required" for="sku"><em>*</em><?php echo $helper->__('Sku')?></label>
<div class="input-box">
<input type="text" name="sku" id="sku" class="required-entry input-text" value="<?php echo $mpAssignProductModel->getsku() ?>"/></div></div></div></li>
</form>

i upload to this form and store it db my problem if same sku also upload how i restrict that.

1 Answer 1

1

You should first validate any data on forms using a client side validation like javascript. If you have more complex functions like a duplicate lookup you can accomplish this through an AJAX call to the database to see if that value already exists.

Finally, you should also validate your data in your model to ensure that you are not going to throw an error on the database insert.

Of course you should also do a catch on your function to capture any potential errors and report them via the Magento log function.

1
  • can you please send me any example or code Commented Nov 5, 2015 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.