1

I currently develop a FieldPlugin for myself. I noticed some things and don't understand them fully right now. My plugin works in the backend perfect, but raises errors on the frontend, so I did some investigating.

How I've done things until now also might be not the right path.

First fact why my plugin worked until now: If you're hitting the Save button in article edit the method onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form) gets called.

In this method, I saved $field->value in a member variable for usage in onContentBeforeSave($context, $item, $isNew, $data = array()). (Yes, this is the part where I think I used the wrong way.)

But what I don't understand is why, in this action, the variable $field has different values in the front and backend.

In frontend:

stdClass Object (
    [id] => 1
    [title] => Fileupload
    [name] => fileupload
    [checked_out] => 0
    [checked_out_time] => 0000-00-00 00:00:00
    [note] => 
    [state] => 1
    [access] => 1
    [created_time] => 2019-07-14 16:25:05
    [created_user_id] => 478
    [ordering] => 0
    [language] => *
    [fieldparams] => Joomla\Registry\Registry Object (
        [data:protected] => stdClass Object (
            [savePath] => /images/fileupload 
            [downloadProtection] => 1
        )
        [initialized:protected] => 1
        [separator] => .
    )
    [params] => Joomla\Registry\Registry Object (
        [data:protected] => stdClass Object (
            [hint] => 
            [class] => 
            [label_class] => 
            [show_on] => 
            [render_class] => 
            [showlabel] => 1 
            [label_render_class] => 
            [display] => 2 
            [layout] => 
            [display_readonly] => 2
        )
        [initialized:protected] => 1
        [separator] => .
    )
    [type] => jtfileupload 
    [default_value] => 
    [context] => com_content.article 
    [group_id] => 0 
    [label] => Fileupload 
    [description] => 
    [required] => 0 
    [language_title] => 
    [language_image] => 
    [editor] => 
    [access_level] => Public 
    [author_name] => Super User 
    [group_title] => 
    [group_access] => 
    [group_state] => 
    [group_note] =>
) 

In backend:

stdClass Object ( 
    [id] => 1 
    [title] => Fileupload 
    [name] => fileupload 
    [checked_out] => 0 
    [checked_out_time] => 0000-00-00 00:00:00 
    [note] => 
    [state] => 1 
    [access] => 1 
    [created_time] => 2019-07-14 16:25:05 
    [created_user_id] => 478 
    [ordering] => 0 
    [language] => * 
    [fieldparams] => Joomla\Registry\Registry Object ( 
        [data:protected] => stdClass Object ( 
            [savePath] => /images/fileupload 
            [downloadProtection] => 1 
        )
        [initialized:protected] => 1 
        [separator] => . 
    )
    [params] => Joomla\Registry\Registry Object ( 
        [data:protected] => stdClass Object ( 
            [hint] => 
            [class] => 
            [label_class] => 
            [show_on] => 
            [render_class] => 
            [showlabel] => 1 
            [label_render_class] => 
            [display] => 2 
            [layout] => 
            [display_readonly] => 2 
        ) 
        [initialized:protected] => 1 
        [separator] => . 
    )
    [type] => jtfileupload 
    [default_value] => 
    [context] => com_content.article 
    [group_id] => 0 
    [label] => Fileupload 
    [description] => 
    [required] => 0 
    [language_title] => 
    [language_image] => 
    [editor] => 
    [access_level] => Public 
    [author_name] => Super User 
    [group_title] => 
    [group_access] => 
    [group_state] => 
    [group_note] => 
    [value] => 2019_Kreismeisterschaft_Vaihingen_1807016968.pdf 
    [rawvalue] => 2019_Kreismeisterschaft_Vaihingen_1807016968.pdf 
)

So why exists in the object in backend the part value and rawvalue and in front end not?

Edit: I created a tag if someone wants to look into the code and test it on his own. https://github.com/JoomTools/plg_fields_jtfileupload/tree/JoomlaExchange

  • 1
    where do you check your variable (in the backend)? Before saving in database of after saving in database? I mean, are you sure, your value (value, rawvalue) is stored in database? Is it loaded when you save the items? When your value (value, rawvalue) is stored in database, are you sure that the place in frontend loads it? Is there standard load of items or some customized which loads standard values including your newly created values? – Phoca Jul 21 at 9:11
  • @Phoca I have moved your "answer" to a comment (where it belongs). Please take the tour and try to earn 41 more rep at SO, so that you get an instant +100 rep here and the privileges that come with it. I am referring to the association bonus. – mickmackusa Jul 21 at 10:33
  • @Phoca yes it is stored. If I load the article and go to edit in frontend, value and rawvalue are in the object. If I then press save and look into the object, value and rawvalue are not in there. I don't know if it is a bug or sec feature to hide those two values. I check the same object in front and backend before, onsave and after save. – svanschu Jul 21 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.