Context, data and query in form helper

Hi everyone,

I’m reading documentation about form helper, but I don’t really get the part “values resources”. Is it about setting default value for input tag?

Thank you.

Yes, that’s correct. It mostly applies to editing existing records, but there are other scenarios too, like setting default values for new records.

Thank you for your reply, So I wonder how it is different between context, data and query? I can understand the difference between query and data (the form will parse data from get and post methods).

But I don’t really get context? Is it for the scenario that you described (setting default values?).

Right now, I am using $this->set(); multiple times in one controller whenever I have to send a new context to the view. I wonder if this is the right way?

Thank you for your help!

The context is 1st argument you pass to FormHelper::create(), which is usually an entity, resulset or Form class instance.