Magento – How to increase custom attribute’s text field limit

productproduct-attribute

I have a custom product attribute with input type "Text Field" .So generally magento is allowing to enter maximum 255 characters into this.

Now my query is,I don't want to limit characters into text fields. Admin can enter more then 255 characters in this custom attribute.

Best Answer

This might help you: here first name is the custom option. so change the max length value.

$productData = Mage::getSingleton('core/session')->getProductData();
$product_id = $productData['id'];
$product = Mage::getModel('catalog/product')->load($product_id);


 <?php foreach ($product->getOptions() as $_option): ?>
                    <?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD): ?>
                        <?php if (stristr($_option->getTitle(), "first name")): ?>
                            <div class="form-group row">
                                <label class="col-sm-4 control-label line" for="options_<?php echo $_option->getId() ?>_text"><?php echo $_option->getTitle(); ?></label>
                                <div class="col-sm-8">
                                    <input  title="Enter <?php echo $_option->getTitle(); ?>" <?php if($_option->getMaxCharacters()): ?>maxlength="<?php echo $_option->getMaxCharacters() ?>"<?php endif; ?> type="text" value="<?php if (isset($options[$_option->getId()]))
                    echo $options[$_option->getId()]; ?>"  placeholder="" autocomplete="off" id="firstname" class="form-control <?php echo $_option->getIsRequire() ? ' required-entry required' : '' ?> <?php echo $_option->getMaxCharacters() ? ' validate-length maximum-length-' . $_option->getMaxCharacters() : '' ?> product-custom-option" name="options[<?php echo $_option->getId() ?>]"/>
                                </div>
                            </div> 
                        <?php endif ?>