column_default.twig 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {# here we put 'NONE' as the default value of drop-down; otherwise users would
  2. have problems if they forget to enter the default value (example, for an INT) #}
  3. {% set translation %}{% trans %}None{% context %}for default{% endtrans %}{% endset %}
  4. {% set default_options = {
  5. 'NONE': translation,
  6. 'USER_DEFINED': 'As defined:'|trans,
  7. 'NULL': 'NULL',
  8. 'CURRENT_TIMESTAMP': 'CURRENT_TIMESTAMP'
  9. } %}
  10. {# For a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value #}
  11. {% set default_value = '' %}
  12. {% if column_meta['DefaultValue'] is defined %}
  13. {% set default_value = column_meta['DefaultValue'] %}
  14. {% endif %}
  15. {% if type_upper == 'BIT' %}
  16. {% set default_value = Util_convertBitDefaultValue(column_meta['DefaultValue']) %}
  17. {% elseif type_upper == 'BINARY' or type_upper == 'VARBINARY' %}
  18. {% set default_value = bin2hex(column_meta['DefaultValue']) %}
  19. {% endif %}
  20. <select name="field_default_type[{{ column_number }}]"
  21. id="field_{{ column_number }}_{{ ci - ci_offset }}"
  22. class="default_type">
  23. {% for key, value in default_options %}
  24. <option value="{{ key }}"
  25. {%- if column_meta['DefaultType'] is defined
  26. and column_meta['DefaultType'] == key %}
  27. selected="selected"
  28. {%- endif %}>
  29. {{ value }}
  30. </option>
  31. {% endfor %}
  32. </select>
  33. {% if char_editing == 'textarea' %}
  34. <textarea name="field_default_value[{{ column_number }}]"
  35. cols="15"
  36. class="textfield
  37. default_value">{{ default_value }}</textarea>
  38. {% else %}
  39. <input type="text"
  40. name="field_default_value[{{ column_number }}]"
  41. size="12"
  42. value="{{ default_value }}"
  43. class="textfield default_value" />
  44. {% endif %}