Default Value on Hidden field

Hello everyone,
I’m in CI4 using the last version on GCEnt.
I’m trying to set a default value on a hidden field.
How can I achieve that?

I’ve tried lots of combination without any success:

$crud->fieldTypeAddForm(“welcome_message”, “hidden”,null,[“value”=>“hello”]);

Hello @portapipe and welcome back :hugs: :hugs: :hugs:

The fieldType is only to change the fieldType and we don’t support the value for hidden fields with the same function. We have split this to different functions just for better readability. So in order to achieve that you should use the function callbackAddForm

So in your case this is how your code will look like:

$crud->fieldTypeAddForm('welcome_message', 'hidden');
$crud->callbackAddForm(function ($data) {
    $data['welcome_message'] = 'your-default-value';

    return $data;
});

Let me know if that helped.

Regards
Johnny

Uuuuh that helped! I’ll try, thanks!
Hope everything is fine, It’s been long time!

Yes, everything well… (as well as it can be with a pandemic :slight_smile: ) I hope the same for you.

Many things has changed in Grocery CRUD Enterprise (in comparison with the community edition) I will try to create an article for it.

Regards
Johnny

Yeah pandemic didn’t help a thing actually. Happy to hear everything is good for you and family!

Glad to get finally the Enterprise Edition! I’m in worry and I need to get everything done asap of course, and the change are a lot for a “quick swap”. I need more examples for sure! Articles, videos, more documentations, tutorials… ANYTHING PLEASE! Docs are the main structure of a well made project!

And BTW I’ve updated my famous GroceryCrud-Login plugin locally to work with community&enterprise Codeigniter 4 setup!
I’ll release when I’m sure everything is working properly.

So the engine is all new, right? Good to know! Need to get how to make few things, like if I have a single row and I don’t want the list, what should I use to show just the edit view? And if I want to use a more stable TinyMCE (the configuration is easier and the project is more followed than CKEditor, for example the file uploader in the editor is vital for several projects) can I change to it?

Lots of questions as you can see, but for big projects they need lots of tools :slight_smile:

(I like to know everything of GCEnt so I can help other people and manage the framework at the top levels)