Validation and select fields (Cake/2.5)

FormHelper::input() adds automatically lots of fancy stuff I need:

  • Display a label
  • Tag required fields with an asterisk
  • Highlight fields that failed validation
  • Display validation errors

However, FormHelper::select() doesn’t do anything of this. I’m forced to replicate all the stuff manually.

Is that the way it’s meant to be?

FormHelper::input() doesn’t just generate <input> but <select>, <textarea> etc. too. So if you want a <select> with all the other “fancy stuff” just use FormHelper::input() with 'type' => 'select' in it’s $options argument.

1 Like