Extract attr_rw from Formula for reuse

Closes #20239.