Search code examples
sqlitecakephpcakephp-3.0formhelper

SQLite: How to set default input type to `text` instead of `textarea`


I am using sqlite in my Cake project, where VarChar data type is not exists, and the inputs comes as textarea.

<textarea name="name" required="required" id="name" rows="5">Value</textarea>

I wonder if there is a way to make the default type setted to text and not textarea.

<input type="text" name="name" id="name" />

Solution

  • SQLite does have/recognize a VARCHAR data type too, it's just being resolved internally to the generic storage type TEXT.

    So while it doesn't make a difference to SQLite whether you are using CHARACTER, VARCHAR, NCHAR, TEXT, etc, it will make a difference for CakePHP when it inspects the schema.

    So, long story short, use VARCHAR and you're set (don't forget to clear the model cache (tmp/cache/model) after making changes to the schema).

    See also https://www.sqlite.org/datatype3.html