[CakePHP]beforeValidateでintegerのフィールドのみ全角数字を半角数字に置き換える

表題のメモです。

Modelにて。

	public function beforeValidate($options = array()) {

		$columnTypes = $this->getColumnTypes();
		foreach ($this->data[$this->alias] as $field => $value) {
			if (!empty($value) && $columnTypes[$field] === 'integer') {
				$this->data[$this->alias][$field] = mb_convert_kana($value, 'n', 'UTF-8');
			}
		}
		return true;

	}

表題修正

スポンサーリンク
336x280_1
336x280_1

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク
336x280_1