cupcake icon indicating copy to clipboard operation
cupcake copied to clipboard

Presentation

Open webbird opened this issue 4 years ago • 2 comments

I just stumbled across your new library and like the humor. :) Good work so far! Are you going to implement some kind of "presentation layer"? What I mean is: A user can choose a "flavor" like "Bootstrap" or similar and the lib just adds the appropriate class names to the elements. I know that this is not much fun, but I think it would help to create good looking forms with nearly no effort.

Edit: I think the "flavor" would / should / could make use of already existing methods like $x->setBeforeEach('<div class="form-row">')

You could also name it "topping" so it makes more sense if the user calls it at the end of the form creation. :D

webbird avatar Aug 19 '21 15:08 webbird

Yes, this is something I want to do.

We already have Blends e.g. https://github.com/soatok/cupcake/blob/master/src/Blends/MultiCheckbox.php

Before I get to the higher-level presentation stuff, I wanted to make sure the low-level functionality covers 100% of the HTML5 Form specification. Then, I want to make it easy to dive in and manage these elements (think jQuery versus 2008-era vanilla JavaScript). Once the utility is completely implemented, my next focus was going to be on convenience methods.

soatok avatar Aug 25 '21 08:08 soatok

This is great news! I am interested in replacing my own FormBuilder, and Cupcake is the first alternative I like. :D

A special feature of my own form builder is the possibility to store the configuration of the form completely as an array. A field definition may look like this:

    array(
        'type'        => 'select',
        'label'       => 'Update frequency',
        'name'        => 'sitemap_update_freq',
        'options'     => array(
            'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'
        ),
        'selected'    => 'weekly',
        'class'       => 'fbleave', // CSS class(es)
    )

There are more options like "required", "value" (set a default value), "allow" (attach validation) or even "title" (some description to be added as "title" attribute). Should be easy to create importers for Cupcake, first from JSON and PHP array. Later there can be importers from database and other sources, too. Would you prefer this to be a separate project? Are you interested anyway?

webbird avatar Aug 25 '21 10:08 webbird