TomPich Posted October 28 Share Posted October 28 (edited) Hello friends, I stumbled upon a problem that is harder to solve that I thought. On a template, the user can upload a file. The description of the file is used in the front as text for the download button. The client asked me to have a default description for this field (Communiqué). So I started to play with some hooks (in admin page), mainly addHookAfter InputfieldFile::processInputFile This is where I am for now... $wire->addHookAfter('InputfieldFile::processInputFile', function (HookEvent $event) { $field = $event->object; if ($field->attributes["name"] === "postFile") { // fill the file description with "Communiqué de presse // but I can’t figure out how to do that }; }); Any help? Thanks! Edited October 28 by TomPich Correct typo Link to comment Share on other sites More sharing options...
Sanyaissues Posted October 28 Share Posted October 28 wire()->addHookBefore("InputfieldFile::renderItem", function(HookEvent $event) { $pagefile = $event->argumentsByName('pagefile'); if ($pagefile->field->name === 'yourFileField') { $pagefile->description = 'Communiqué de presse'; $pagefile->page->save($pagefile->field->name); } }); Try this @TomPich. 1 1 Link to comment Share on other sites More sharing options...
TomPich Posted October 29 Author Share Posted October 29 (edited) Thanks! It works perfectly. I didn’t know about the "pageFile" argument. I wonder where I could have find this 😅 Edited October 29 by TomPich Update Link to comment Share on other sites More sharing options...
Sanyaissues Posted October 30 Share Posted October 30 When you’re feeling lost and already halfway to uncharted waters, there’s only one man to call: The Captain Hook. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now