Fork me on GitHub

AutoForm example

The following controller (yes, it's a Zend_Controller) produces the form as seen on the screenshot below.

<?php
class MemberController extends Kwf_Controller_Action_Auto_Form
{
    protected $_buttons = array('save');
    protected $_modelName = 'Members';
 
    protected function _initFields()
    {
        $this->_form->add(new Kwf_Form_Field_TextField('firstname', trl('Firstname')))
            ->setAllowBlank(false);
        $this->_form->add(new Kwf_Form_Field_TextField('lastname', trl('Lastname')))
            ->setAllowBlank(false);
        $this->_form->add(new Kwf_Form_Field_TextField('title', trl('Title')))
            ->setWidth(300);
        $this->_form->add(new Kwf_Form_Field_Select('sex', trl('Sex')))
            ->setValues(array('male' => trl('Male'), 'female' => trl('Female')))
            ->setAllowBlank(false);
        $this->_form->add(new Kwf_Form_Field_DateField('birth_date', trl('Birthdate')));
        $this->_form->add(new Kwf_Form_Field_File('Picture', trl('Photo')));
        $this->_form->add(new Kwf_Form_Field_GoogleMapsField('position', trl('Position')));
    }
}
 

The only thing left are some lines of JavaScript that show this form.

new Kwf.Auto.FormPanel({
    controllerUrl: '/member',
    renderTo: 'memberform'
});
open
Blogs
koala-framework / koala-framework