63 | | <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script> |
| 63 | <script type="text/javascript"> |
| 64 | var adminform = document.forms["{{ opts.module_name }}_form"]; |
| 65 | var first_field = adminform["{{ adminform.first_field.auto_id }}"]; |
| 66 | if(first_field !== undefined) { |
| 67 | first_field.focus(); |
| 68 | } else { |
| 69 | // First field could be datetime split into two fields. |
| 70 | // For example: id_created_datetime_0 |
| 71 | first_field = adminform["{{ adminform.first_field.auto_id }}_0"]; |
| 72 | first_field.focus() |
| 73 | // In the very exceptional circumstance that the |
| 74 | // first_field is still undefined let it error. |
| 75 | } |
| 76 | </script> |