views:

54

answers:

3

ex.

<Form>
  <input type="text"/>
  <span style="display block">your text should be between 4-8 chars</span>
</form>

anyhow just need some kind of pregenerated hint message so I can show hint using JS(Jquery) afterwile what is best way to deal , extending the parent class or is there some other way?

A: 

This article may be useful for you: http://www.smashingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-css-dhtml/

anthares
A: 

If you want to use this text as additional description, use

Zend_Form_Element::setDescription()

If you want to have this as a tooltip of the input element, use

Zend_Form_Element::setAttrib()

If you want this to show as an error message, set the appropriate validator.


Reference:

Gordon
A: 

My 2c, don't use Zend_Form, work directly with view helpers, as in:

<?php echo $this->formText('email', '[email protected]', array('size' => 32)) ?>
<div .tip>bla bla </div>

I find ZF Zend Form way too obtrusive, it has only few really useful cases.

clyfe
-1 for calling Zend Framework obtrusive. ZF has a use-at-will architecture and can be integrated into almost anything with few to very little dependencies. Try to do that with a full stack framework.
Gordon
+1 because I think Gordon is being a little unfair.ZF _is_ obtrusive. Yes, there are components you can use separately, but even the simplest winds up being an exercise in frustration. Particularly when you find the documentation incomplete, or that you have to instantiate about 6 different classes in order to perform a simple operation.The reason full stack frameworks are so useful is because they enforce conventions. ZF has sat on the fence so long that there are almost no best-practice guides on how to use its components.I feel the implementation of Zend Form is broken.
Stephen Orr
ZF == Zend_Form not Zend_Framework, sorry for ambiguity. The Zend Framework sucks at ORM level, has a powerful ORM but needs a lot of effort, also slow to get started for beginners. it definitely needs a bootstrap generator.
clyfe
@Stephen Not wanting to sound like a fanboy here, but what exactly are you missing in the ZF docs? There is wiki, an active community, a ref guide, coding standards, performance guide, project structure guide, the API and devzone has articles on the packages regularly. Also, which component does ZF have, which you cannot run out of the box or which doesn't offer sensible defaults? I agree Zend_Form is somewhat complicated to get into, but there is plenty of tutorials about it and it can be customized to death.
Gordon
@clyfe I agree that ZF is complicated for beginners, but then again, beginners shouldn't start with a framework anyway. ZF has one of the cleanliest OO designs I have seen in a framework. It uses a lot of design patterns and if you don't know these, it will make your coding life difficult. Also, ZF has no real ORM. The Zend_Db classes offers the data access patterns from PoEAA, but these are not mapping to any model classes on purpose, because ZF leaves it to the developer to design the Model, because the Model is the application. If you want an ORM, use Doctrine.
Gordon
@Gordon Zend_Table is a data mapper, the ORM in Zend I was talking about. Compared to ActiveRecord in rails the workload for Zend_Table is huge ie. "sucks". ORM does not mean "for each table a class" it means "map your objects (models) to your relational storage (db)". ZF has one of the cleanliest OO designs. True. It is my framework of choice in php. But imho Zend_Form and Zend_Table, though they are great implementations of their patterns, make you work too much to accomplish your goals.
clyfe
@Gordon I overcome this by implementing my own Clyfe_Active_Record model, validate and filter on model like rails does, and use helpers in views for forms-elements/form-errors displaying (also like rails).
clyfe
@clyfe I wouldn't call Zend_Db_Table a DataMapper. It's a Table Data Gateway that returns Row and Rowset objects. They represent the DB structure 1:1 down to the relations, but the structure is ultimately tied to the structure in the DB. Change one and you change the other. A DataMapper keeps Object and DB independent from each other. AR is not doing this either. In fact, AR ties the DB to your objects even closer than TDG due to inheritance. If you want RoR style AR, try http://www.phpactiverecord.org. Also ZF never aimed to be the next RoR. Use Cake if you want RoR.
Gordon
@clyfe Also, no one said you do have to use Zend_Db_* or Zend_Form at all. This seems to be a common misconception. Like said in the beginning, ZF has a use-at-will architecture. This gives ZF a flexibility beyond any other PHP framework. If you don't like the DB package, don't use it, use Doctrine, Propel or whatever you like. That's not uncommon. If you don't like Zend_Form, use whatever you find more appropriate. Use your approach if you like. This flexibility is exactly why I think ZF or Zend_Form is not obtrusive and why I downvoted the answer (even though the approach you give works).
Gordon
@Gordon Zend_Table is implements indeed Table Data Gateway, I was hasty, but still is an ORM. I know about Cake i prefer ZF, has cleaner API. Zend_Form IS obtrusive IF you use it, compared do my described approach. The matter is subjective anyway, and we each are entitled to our opinions. I said "dont use it because is cumbersome" and you say "it's not cumbersome because you are able not to use it" ...
clyfe
@clyfe It's not only not cumbersome, because you don't have to use it, but because you don't have to use all it offers. You can still very much use it as form renderer only and do the validation in your model like you described. Valid approach, but let's agree to disagree then and thanks for the healthy discussion :)
Gordon
Looks like I missed the argument :) I've read through the comments though, and I have to clarify my point of view.Zend Framework is by far the most powerful PHP framework. It's also the most enterprise-friendly, due to the commercial support being available. However, I feel that it suffers from trying to do too much. The fact that it implements design patterns is nice, but were they really necessary to get the job done, or could the task have been approached more simply? In my eyes, Zend Framework suffers from trying to be Java with PHP syntax.But I'll agree to disagree too :) YMMV!
Stephen Orr