-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename FormField NS to Form\Control (and FormLayout to Form\Layout) #1311
Conversation
I like the idea about the Form namespace. However, I know at least of 3 people (me included) that confused Model Fields and Form Fields when starting with ATK. My idea to avoid this was to refer to Form Fields as FormField always (Docs, Methods, whatever). So Form would have getFormFields(), getFormField() methods etc. I doubt having Form/Field namespace alone will do the job to avoid this confusion in future. How about Form/FormField? Also see #794 |
@PhilippGrashoff the idea is to force always use the Form namespace which will also solve the problem for newcomers |
31206b7
to
7d3c35c
Compare
b04ed01
to
831f34a
Compare
831f34a
to
17af54e
Compare
@georgehristov FormField rename - this is valid only if you can guarantee than FormField can not be used on its own without a Form - is this 100% true? Based on my search it is currently used at least in Grid for searchbox /wo Form. Please comment on this case. Based on my research the /wo is valid by html spec - https://stackoverflow.com/questions/3294572/is-input-well-formed-without-a-form . With the same reasoning, the FormLayout can (does it work now in Atk now?) be used without Form probably too.This is also related with my PR #1275 to support nested forms. We may simply always require a form to support all features. Only with this approach we can guarantee, that the input in for. ex. Grid was not mistakely wrapped inside another form (thus it is not serialized etc). How does other popular frameworks, even not PHP ones, solves this? |
We are mixing several issues here:
|
it is not, because this can very easily imply that decision to move it under Form NS si wrong - it can be used without Form, it is just one of a View building block addable to anywhere, element, which can be used in Form but you do not have too. But I think this is a step in the right direction and there are no additional downsides (like with your other refactoring PRs). I will check now. After mergin this, we should:
|
a19c89f
to
79d500d
Compare
79d500d
to
614602f
Compare
two cosmetic changes to fix, then we can merge it this afternoon because it is almost BC |
This reverts commit 356ddba.
Ah, Control is nice :) |
@PhilippGrashoff thanks for feedback, I mean for both! :D |
fixes #794
Introduce Form namespace
atk4\ui\Form
namespace onlyremoves duplicate class names like
Generic
renames classes according to PSR
docs updated with explicit variable naming and new namespace importing for clarity, e.g.
$group->addField('gender', [Form\Control\Dropdown::class, 'values' => ['Female', 'Male']]);
$f
->$form
,$gr
->$group
, etcBC break:
instanceof
operator returns false if tested against the old class namesAutoload of old classes will trigger
DEPRECATED
warningMigration:
Simple regex:
(?<!\w)FormField(?!\w)
Search/replace in files
FormField\Generic
toForm\Control
FormLayout\Generic
toForm\Layout
atk4\ui\FormField
toatk4\ui\Form\Control
atk4\ui\FormLayout
toForm\Layout
FormField\CheckBox
toForm\Control\Checkbox
(change of class name case only)FormField\DropDown
toForm\Control\Dropdown
(change of class name case only)FormField\DropDownCascade
toForm\Control\DropdownCascade
(change of class name case only)FormField\MultiLine
toForm\Control\Multiline
(change of class name case only)FormField\UploadImg
toForm\Control\UploadImage
FormField\TextArea
toForm\Control\Textarea
(change of class name case only)