platform
platform copied to clipboard
Improve naming and separation of attributes for input fields
Problem:
Currently, to set a label above an input field, the title method is used:
Input::make('name')
->title('Your name')
However, using title is not entirely correct, as in HTML the title attribute is intended to provide advisory information about the element, not for displaying the main label of the field.
Proposed solution:
Introduce a separate label method for the main field label, keeping title for advisory or helper text. This aligns with practices in Bootstrap, Windows Forms, and other popular UI frameworks:
Input::make('name')
->label('Your name') // Main label above the field
->title('Enter your name here') // Hint or advisory information
Benefits of this separation:
- Correct terminology and semantic meaning.
- Greater flexibility when building interfaces.
Backward compatibility:
To avoid breaking existing code, the title method can remain. If label is not set, its value can be automatically assigned from title. This will preserve the current behavior.