Jump to content

Module: FormStyler


MuchDev
 Share

Recommended Posts

post-2490-0-73373900-1446889441_thumb.jp

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

post-2490-0-62729100-1446888765_thumb.pn

  • Like 13
Link to comment
Share on other sites

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

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?  :-X
 

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

  • 4 weeks later...

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).

  • Like 1
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...