Hello,

IMHO in this case the most easy way to use CSS classes with prefixes:

// CSS:
.__foo { color: #0c0; }


// Form:
$form->addElement('text', 'foo', array('class' => '__foo'));


For the situation when you want to keep JS and CSS as a separate files.
But if you are OK to use inline, then I guess another approach will be
much more preferable:

// Inline JS:
var element = document.getElementById(<?=$form->getElement('foo')->getId();?>);

// Inline CSS:

input#<?=$form->getElement('foo')->getId();?> { color: #0c0; }


2010/2/17 Hector Virgen <[email protected]>:
> If you're using HTML4, then it's based on the name, but if you're using
> XHTML1 then it's based on the ID.
> Why can't you use the existing IDs?
> // javascript
> var element = document.getElementById('username');
> // css
> input#username{ color: #0c0; }
>
> --
> Hector
>
>
> On Tue, Feb 16, 2010 at 11:23 PM, mathieu.suen <[email protected]>
> wrote:
>>
>> Hector Virgen wrote:
>>>
>>> The ID is based on the name of the element. If your element it named
>>> "lock" the ID will be "lock", or if using subforms, will be
>>> "{subform}-lock".
>>>
>>> If you mess with the ID's, Zend_Form won't know how to handle the posted
>>> data because browsers post data based on the IDs of the inputs.
>>
>> No, that's base on the name not the IDS
>>
>>>
>>> Why do you need to change the ID?
>>
>> Javascript, css stuff.
>>
>>>
>>> --
>>> Hector
>>>
>>>
>>> On Tue, Feb 16, 2010 at 12:31 AM, mathieu.suen
>>> <[email protected] <mailto:[email protected]>> wrote:
>>>
>>>    Саша Стаменковић wrote:
>>>
>>>        Chage
>>>
>>>        $mySubForm->getElement('lock')->setAttribs('id', 'lock' .
>>>        $server->getUniqueId());
>>>
>>>        to
>>>
>>>        $mySubForm->getElement('lock')->setAttrib('id', 'lock' .
>>>        $server->getUniqueId());
>>>
>>>
>>>    Actually I mean setAttrib. The issue still remain.
>>>    The more I dig in the code the more I get made at it.
>>>
>>>    Adding design patter is a good things but in that situation it is
>>>    harmful.
>>>
>>>
>>>        Regards,
>>>        Saša Stamenković
>>>
>>>
>>>
>>>        On Tue, Feb 16, 2010 at 9:06 AM, mathieu.suen
>>>        <[email protected]
>>>        <mailto:[email protected]>
>>>        <mailto:[email protected]
>>>        <mailto:[email protected]>>> wrote:
>>>
>>>           Hi,
>>>
>>>           How do you setup the id of form element?
>>>           I try this:
>>>
>>>           $mySubForm->getElement('lock')->id = 'lock' .
>>>        $server->getUniqueId();
>>>
>>>           and also:
>>>
>>>           $mySubForm->getElement('lock')->setAttribs('id', 'lock' .
>>>           $server->getUniqueId());
>>>
>>>           But non of the above work.
>>>
>>>           It always yield something like : subForm-myuniqueid-load
>>>
>>>           Then I decide to look at the code and found out that is
>>>        completely
>>>           odd and really not well design IMHO.
>>>
>>>           So if you have any idea thanks
>>>
>>>           --Mathieu Suen
>>>
>>>
>>>
>>>
>>>
>>>
>>>    -- Mathieu Suen
>>>
>>>
>>>
>>
>> --Mathieu Suen
>>
>>
>>
>
>



-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 617 179 344
Homepage: http://www.ixti.ru
JID: [email protected]

*Origin: Happy Hacking!

Reply via email to