A Preston man arrested on suspicion of attempted murder after an attack outside a primary school has been detained under the Mental Health Act.