soatok / cupcake

PHP library for simply secure HTML forms (generation and processing). Secure-by-default.

Home Page:https://soatok.blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Presentation

webbird opened this issue · 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

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.

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?