SimpleRain / SimpleOptions

A simple wordpress options framework for developers.
16 stars 2 forks source link

Implement legacy SMOF fields #4

Closed dovy closed 11 years ago

dovy commented 11 years ago

@Smartik89 Feel like working on this at all or not up to it? I understand if you prefer SMOF...

awps commented 11 years ago

I don't know if I understand your question corectly, but anyways, I don't like how SMOF is created.

For this framework I would sugest using another logic. First step would be to separate all fields type in a PHP class. Example:

class SimpleOptions_Fields {
    function text($id, $name, $value, $class){
         //maybe some tests before we use the data
         //...
         //HTML
         $output = '<input type="text" id="'. $id .'" name="'. $name .'" value="'. $value .'" class="'. $class .'" />';
         return $output;
    }
    function select($arguments, $arg, ...){
         //code here...
    }
}

Use these fields in our framework:

//...
//Jump direct to switch
switch ($value['type']) {
    case: "text"
        $output .= SimpleOptions_Fields::text($id, $name, $value, $class);
    break;
    //...
    case: "select"
        $output .= SimpleOptions_Fields::select($arguments, $arg, ...);
    break;
    //...
}
//...

This way we can re-use these fields in many ways, combine them or use for multiple purposes. What do you think?

dovy commented 11 years ago

@Smartik89 That's exactly right! Check this out: https://github.com/SimpleRain/SimpleOptions/tree/master/options/fields

That's how it's built and how we're going to make it. :)