neonwired Posted May 29, 2019 Share Posted May 29, 2019 Is there a way to prefill a field with a default value. I have a simple text field that 99% of the time will contain the same text but for the other 1% it needs to be editable so rather than paste in the same text for nearly every page I'm trying to find away to prefill the value of the input. Link to comment Share on other sites More sharing options...
elabx Posted May 29, 2019 Share Posted May 29, 2019 The field has an option for a default value though it will only apply to newly created pages (in case you have previously created some of them). My bad, this does not exist haha, I think only integer has this. But you could certainly do this with an "after hook" on ProcessPageEdit::buildForm and edit the value of the field in question. I dont have an immediate example but there is probably some around the forum Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 29, 2019 Share Posted May 29, 2019 You could edit the output in the template file and use the new $page->if() method. https://processwire.com/api/ref/page/if/ So there might be no real need in setting a real value. Add a note or description to tell and explain editors the field behaviour. You could define that default value somewhere in your config.php or even in a dedicated settings page to keep it editable - at least for superusers. 2 Link to comment Share on other sites More sharing options...
neonwired Posted May 30, 2019 Author Share Posted May 30, 2019 22 hours ago, wbmnfktr said: You could edit the output in the template file and use the new $page->if() method. https://processwire.com/api/ref/page/if/ So there might be no real need in setting a real value. Add a note or description to tell and explain editors the field behaviour. You could define that default value somewhere in your config.php or even in a dedicated settings page to keep it editable - at least for superusers. Thanks, that's one way if i can't hook something. It'd be nice to have a default field though. 2 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