shadowprince / forman
Form component for shadowprince/slimext
0.2.3
2013-11-19 14:00 UTC
Requires
- php: >=5.2.0
- shadowprince/slimext: *
README
Forman is library for working with forms.
in code
$form = new \Forman\Form( new \Forman\Field\Value("email"), new \Forman\Field\Text("text"), (new \Forman\Field\Checkbox("subscr"))->setValue(1) ); if ($data = $form->process($_POST)) { // send email } render_template("contact.html", array( "form" => $form->getRenderer("\Forman\Render\HTML\Renderer") ->setAction("/contact") ->GET(), ));
in template
{{ form.render|raw }}
or
{{ form.top|raw }} That's my form {{ form.elements|raw }} {{ form.bottom|raw }}
or even
<form action="{{ form.getAction }}" method="POST"> {% for field in form.getFields %} {% if field.getCaption %} <label class="caption">{{ field.getCaption }}</label> {% endif %} <span class="field"> {{ field.renderTag|raw }} </span> {% if field.getHint %} <span class="hint"> {{ field.getHint }} </span> {% endif %} {% endfor %} </form>
Forman writed for slimext, but not attached to it, you can use it with any framework or without it. Additional parameters to process
passed to form validators (you can provide orm object or application instance).