Have form classes changed in 4.2.1

Using the 2 columns as documented here http://agiletoolkit.org/doc/form/styling is not working in 4.2.1

$f->setFormClass('basic atk-form-basic-2col');

Has the way to do it changed?

Answers


Yes, forms support only "stacked" class now, which puts variables above the labels. Forms no longer have their own layout, but they use the default grid system. For example if you assign "atk-grid" column to the form, then use "span3" on your fieldset you get vertical form blocks.

If you assign atk-row class to fieldset and use span3 on field, you will get horizontal form blocks.

To set form class: $form->setClass('atk-row')

The first field-set is already included in the template, so to change that: $form->template->trySet('fieldset', 'span4');

Subsequent field-sets can be set with $form->addSeparator('span5');

Individual field classes are through $field->setAttr('class','...');

Example (model-based form with horizontal layout):

$form=$this->add('Form')->setClass('stacked');
$form->template->trySet('fieldset','atk-row');
$form->setModel('User');

foreach($form->elements as $field){
    if($field instanceof Form_Field){
        $field->setAttr('class','span3');
    }
}

// If you want to separate fields into 2 rows:
$sep=$form->addSeparator('atk-row');
$form->add('Order')->move($sep,'middle')->now();

To simplify all this, you can use custom form templates. Find form.html and compare it with form_horizontal.html in the latest Github master. This should give you good idea how you can create your own form layouts. It's not like Agile Toolkit has only one way to build forms.

p.s. I have updated documentation page to have incompatibility warning.


Need Your Help

PayPal IPN and Simulator - Is SSL Required

java paypal paypal-ipn paypal-sandbox

I am trying to work with the PayPal IPN simulator to get my development underway.

javascript save/load image + text data from client side

javascript image load save blob

I want users of my page to be able to save and load data (single file) which contains images and numerical values.