Changed:

$field .= ' checked';

to:
if ($i == 0) $field .= ' checked';

because without correction all attributes were selected.

More...