-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
[REF] CustomField code cleanup #16968
Conversation
(Standard links)
|
'AdvMulti-Select', | ||
]) | ||
) { | ||
if (is_array($fieldValue) && $this->_fields[$name][$fieldName]['html_type'] == 'CheckBox') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The history of this section of code is murky but from what I can tell, this is applying special formatting to checkboxes.
So instead of a double-negative conditional "not field types that are not checkbox" let's just say "if checkbox".
Perhaps @monishdeb can confirm this as the git history suggests he was involved writing this originally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it looks like possible html types are
'CheckBox':
'Multi-Select':
'Multi-Select State/Province':
'Multi-Select Country':
'Select':
'Autocomplete-Select':
'Radio':
'Select Country':
'Select State/Province':
''Select Date'
'File'
'Link'
'Text Area'
'Text'
To validate this we need to confirm that only the top 4 could be arrays at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton so the two ways of writing and evaluating a refactor would be (roughly):
- The code analysis approach: Analyze the original code and figure out what it does based on all possible inputs. Make sure the refactored code behaves exactly the same in all circumstances.
- The "what were they thinking?" approach: Guess what the developer was trying to accomplish (which may not match what the code actually says because developers are only human). Make sure the refactored code satisfies their intentions.
I'm going with number 2, because based on the context (and basically the same code being duplicated in many other places) that this block is for the sake of checkboxes only, even though that's not exactly what it said.
retest this please |
The history of this section of code is murky but from what I can tell, this is applying special formatting to checkboxes. So instead of a double-negative conditional "not field types that are not checkbox" let's just say "if checkbox".
Tested, works fine. good to merge! |
I'm happy with this merge based on @pradpnayak's testing |
Overview
This is some initial code cleanup and refactoring to make CustomFields a bit more consistent.
I'm trying to standardize on using the
isSerialized
method rather than ad-hoc guesswork based on the html_type.