Magento - 强制表单字段将大写值发送到数据库


Magento - Forcing a form field to send upper case values to database

我们想强制注册表单字段输入全部为大写,我<?php @$_REQUEST['firstname'] = strtoupper(@$_REQUEST['firstname']); ?>尝试了这段代码,但它没有帮助。我错过了我们的东西吗?

<div class="field name-firstname">
<?php @$_REQUEST['firstname'] = strtoupper(@$_REQUEST['firstname']); ?>    
    <label for="<?php echo $this->getFieldId('firstname')?>" class="required"><em>*</em><?php echo $this->getStoreLabel('firstname') ?></label>
    <div class="input-box">
        <input type="text" id="<?php echo $this->getFieldId('firstname')?>" name="<?php echo $this->getFieldName('firstname')?>" value="<?php echo $this->escapeHtml($this->getObject()->getFirstname()) ?>" title="<?php echo $this->getStoreLabel('firstname') ?>" maxlength="255" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('firstname') ?>" <?php echo $this->getFieldParams() ?> />
    </div>
</div>

您正在对表单字段值执行 strtoupper,而不是发送到处理表单处理的操作脚本的实际值。尝试在操作脚本上添加 strtoupper,或者如果要确保该值在任何地方都是大写的,请通过查询构造向字段添加 sql UPPER 字符串函数。