MuchDev Posted November 5, 2015 Share Posted November 5, 2015 Helllllo! I am working on a simple module / pet project for a module that inserts custom classes into specific templates for forms that are generated via the api. I use bootstrap a bunch and am always messing with the defaults in processwire, now it should be a simple manner to tweak my settings in the admin area. As this seems to be something that I keep needing I thought that others might as well. Right now the functionality is pretty simple: Select the templates that you want to override the default styling on. Set your new defaults .... Proffit. What I would like is maybe some suggestions for options or functionality that I should try for. I have never really deep dived into modules so this is a bit new to me, but as I am looking for a new development job I would push myself for something cool. https://github.com/MuchDevelopment/FormStyler/tree/master 13 Link to comment Share on other sites More sharing options...
MuchDev Posted November 6, 2015 Author Share Posted November 6, 2015 Alrighty it's all wired up. Well mostly... I am pulling the names of all of the inputfield types like so, but I seem to be missing at least the InputfieldSubmit field. foreach(Wire::fuel('fieldtypes')->find() as $field){ //this is how I pull fieldnames $type = (string)$field->getInputfield($page,new NullField); //some code that doesn't really matter } So what I think is happening is that find is only going to return inputfields that fieldtypes are already using. How would I go about finding these? One other thing I'm working at is getting a way to pull the class and markup data out of the InputfieldWrapper class. Link to comment Share on other sites More sharing options...
MuchDev Posted November 7, 2015 Author Share Posted November 7, 2015 Well I tried to find a way around doing this but I couldn't think of anything else so I just built a little helper class that passes the variables out of InputfieldWrapper. What is the danger here, probably lots right? class DefaultsRouter extends InputfieldWrapper{ public static $defaultMarkup = array(); public static $defaultClasses = array(); public function __construct(array $defaults = array()){ $this->defaultMarkup = InputfieldWrapper::$defaultMarkup; $this->defaultClasses = InputfieldWrapper::$defaultClasses; } } Link to comment Share on other sites More sharing options...
MuchDev Posted November 8, 2015 Author Share Posted November 8, 2015 Alright, had some bugs there as I decided to change the name and didn't update some variables, but I just ran through everything and I'm happy enough with it. Feel free to try it out and let me know. Link to comment Share on other sites More sharing options...
apeisa Posted December 5, 2015 Share Posted December 5, 2015 MuchDev, this looks cool! How about ready presets for most popular css frameworks out there (bootstrap, foundation etc)? Ryan has those in FormBuilder, probably ok to use those in different context too (I have already asked, waiting for answer). 1 Link to comment Share on other sites More sharing options...
MuchDev Posted December 5, 2015 Author Share Posted December 5, 2015 MuchDev, this looks cool! How about ready presets for most popular css frameworks out there (bootstrap, foundation etc)? Ryan has those in FormBuilder, probably ok to use those in different context too (I have already asked, waiting for answer). Thanks man! Yeah I thought of that but then when I started thinking about all of the different frameworks and the amount of different classes I got bored and figured people would just input what they want. I'll look into adding this on my holiday break in a couple weeks (when I will really be working on my padloper implementation too) I wouldn't mind forking some of that code from Ryan, but then his system already does everything I do and much more . I also never figured out a good way for really customizing sizes and such, you can make your field so wide but then every field is the same div around it. Link to comment Share on other sites More sharing options...
Tom. Posted December 5, 2015 Share Posted December 5, 2015 This looks great, I really need to learn more about ProcessWires classes, I've created a lot of forms but I manually code the data to save using: $page->of(false); $p = new Page(); Link to comment Share on other sites More sharing options...
SteveB Posted December 5, 2015 Share Posted December 5, 2015 Great project idea. Would this allow me to use different settings for different templates? I'm making front end forms with the API but the different forms need their styles adjusted independently. 1 Link to comment Share on other sites More sharing options...
MuchDev Posted December 6, 2015 Author Share Posted December 6, 2015 Great project idea. Would this allow me to use different settings for different templates? I'm making front end forms with the API but the different forms need their styles adjusted independently. Thanks man:) In its current and very simple state it will style all templates with the same settings. If you were styling your forms on a template using your own code I would just style them there or make a hook for your specific templates. But....this is a feature I would like to add. I'll look in to in in a week or two. You could also if you are in a hurry make a couple copies of the module for different templates using the same settings and rename the modules for now if you want to use it in it's current state. This is not ideal but it would solve what you need for the moment. Also feel free to fork my code and hack it to hell for your own purposes 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