8 years ago
3
Topic

Hello Octopoos,

I modified an admin form via jQuery to get dynamic fields from another form (because there are many many many), to include them inside special #divs in admin. 

One final-field for each group finally holds the result in json format and saves it to the according database of the admin form.

Because Seblod notices that there are more fields than the known ones, it fires them to the $config. So far so good (good to know feature).

Now to the prob - my jQuery Code is not executed as I expect it via beforeStore method. This seems independent on the type (file or directly).

It is working when I execute it by myself:

jQuery(this).remove(); //where this is an array object of dynamic fieldgroups

I tried this with submit function, on click event and without any special event (cause maybe beforeStore itself declares it, I may^^). - I also put it inside the JS field directly with and without jQuery Syntax.

Could you point me the direction, where I got a brain error, please? How is to execute jQuery Code in beforeStore method - or are there limitations... or do you have another idea why Seblod ignores my remove command and tries to store non-(really)-existing fields?

Thank you in advance, Pierre.

Get a Book for SEBLOD
4229 Posts
Kadministrator
8 years ago
2
Level 1

BeforeStore has 0 effect on the page output so users browser will never see your javascript and since it won't be executed - event is executed on server side before data from the form is stored, to modify fields sent to storage you need to use php as described in tutorial.

Alternatively you could replace submit button with some other button, attach click event to it and then after executing your fields removal code fire regular seblod submit function (this is just an idea, actual code is out of the scope of this forum)

PCo
8 years ago
1
Level 2

Hello Klas,

thanks for your fast reply. I put the click event on the standard apply button(s) inside the beforeRender file and it worked, just not at the beforeStore. 

So this helped. I am just wondering why the beforeStore method does not ignore my (hidden) fields. Do you have an idea, why Seblod acts like this?

Best regards, Pierre.

4229 Posts
Kadministrator
8 years ago
0
Level 3

As I said, page is rendered before beforeStore happens, you can't output anything from here that should be visible to client, you can just change what will go to the databse. BeforeRender on the other hand happens before form is rendered and since you can modify what will be on the page.

Get a VIP membership