Apr 28
Digg
Stumbleupon
Technorati
Delicious

Symfony + wForms

I’ve been using the following library http://www.formassembly.com/wForms/ a couple of times.

There is a topic related to wForms on Symfony:

http://www.symfony-project.com/forum/index.php/m/16632/?srch=wforms#msg_16632

where using of sfFormValidationPlugin is proposed to be used.

Well, I agree that AJAX validation is great solution but in my case I like wForms since they provide cool javascript/css-based solutions for web forms.

Are you interested? If so here is the way how I do that:

1. Download compressed wForms version: http://www.formassembly.com/wForms/v2.0/package/wforms_pack.js
and pickup + download CSS you prefer: http://www.formassembly.com/form-garden.php.

Put wforms.js into js folder and wforms.css into css folder. There may be also a couple of images which I’d recommend to put into images/wforms/ and modify wforms.css so it contains correct path to images.

2. Next step modify your view.yml so it has

stylesheets: [ wforms ]

javascripts: [ wforms ]

3. Put the form html into your templates, e.g.

<fieldset>

<div class=”oneField”>
<label class=”preField”>Name</label>
<?php echo input_tag(‘name’, $sf_data->get(‘sf_params’)->get(‘name’), array(‘size’ => 40)) ?>
<span class=”reqMark”>*</span>
</div>

<div class=”oneField”>
<label class=”preField”>Email</label>
<?php echo input_tag(’email’, $sf_data->get(‘sf_params’)->get(’email’), array(‘size’ => 40)) ?>
<span class=”reqMark”>*</span>
</div>

</fieldset>

That’s it.

As aside note, I’ve figured out that wforms overrides all your forms so if you’d like to have different layout for different forms you’d need to use the following trick (that’s what I figured out but maybe there are better ways):

put your form element into the following tags:

<span class=”oneChoice”>…</span>

and this way you would have wForms style cleaned out.


Author: symfonian

No Comments

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a comment