User tests: Successful: Unsuccessful:
Pull Request for Issues like #19735 and #17801
Yet another alternative for PRs #18188, #17837, #18207, #19742
hopefully a more proper one
If you do not like something in this PR like the fieldnames used to detect field presence
-- then please try to suggest a specific change (specific code !)
Add into the forms an html input tag per field that needs it
such fields are checkbox and checkboxes
$user = JFactory::getUser($USER_ID);
$user->save();
Custom field values are not lost
Form reloads showing none values selected in the checkboxes
Fails, custom field values are lost
Works
?
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries Front End Plugins |
Labels |
Added:
?
|
There HAS to be a way to do this without making form field objects presence aware. The form field objects are NOT data validators!
Title |
|
yes there are other ways
We could do this
RANDID
for every form loadcom_users.user.record_id.RANDID
In such a case this PR would work the same
Honestly i would prefer to use the session solution if other people like it too,
it seems to me that it will be a more clean / proper solution
:sigh:
Sometimes I think I'm talking to myself.
You do NOT need to be aware of presence. The form API does not need to be aware of the pre and post submit states. Your request handler should be doing something very close to what I commented in #19742 (comment) as it relates to fields which can be nullable from the request (i.e. checkboxes) to ensure all fields have values and toggling a checkbox from true to false is handled correctly as a deliberate action.
If you have to put the pre-submit data into the session, you've screwed up in so many ways that I don't even want to try counting.
To be blunt, unless someone is going to fix the code that is reading the data from the request and ensuring that it gets correctly validated/structured BEFORE $form->bind($data);
gets called, I really don't want to see another PR or a modification on an existing one. Because at this point I feel like everybody continues to ignore the broken code and pushes for complete
i thought you did not like the field presence stuff -- added inside the form --
anyway
if we would want to play with words , we can call it 'state' "information" about fields, and forget the "presence" stuff
lets not forget what we want to succeed
anyway i gained some good knowledge about the joomla custom fields inner stuff,
would like to use them for cases like users (when the issue gets fixed)
i ll close this PR and someone else can have a different approach
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-02-21 21:46:21 |
Closed_By | ⇒ | ggppdk |
In short the idea is
if a field always submits a value,
if a field does not submit any value (e.g. when being empty like the checkboxes)
Root issue is that fields plugin is trying to save custom fields values
a. via a JForm submit (controller save task), which may or may have not skipped the field from adding it to JForm (actually this was the only case, we could make this differently)
b. via other code that is to saving the record without setting the custom field values inside the $data['com_fields'] array
Note that after this PR
array()
because missing value means maintain current value, but this is exactly as it should have been in the first place, just making a note of it