Hello,

In this case (CSS tricks) IMHO it's better leave elements with
standard decorators as-is
and mangle them with small JavaScript instead. But in fact, both ways
are not very far
from (or even btter than) simply ViewScript usage. If you don't want
to use ViewScript,
IMHO you better create your own form Element which will return an
array of zipCode and
city, something like this one: http://gist.github.com/402131


2010/5/15 Philip Iezzi <[email protected]>:
> Great, Eugene, thanks a lot!
>
> That's how I did it:
>
>        $city->removeDecorator('Label');
>
> (there is no DtDdWrapper on a standard Zend_Form_Element_Text, so I just 
> removed the "Label" (dt) decorator, the dd tag comes from the "HtmlTag" 
> decorator)
>
> Form element output:
>
> <dt id="zipcode-label"><label for="zipcode" class="required">Zipcode / 
> City</label></dt>
> <dd id="zipcode-element">
>  <input type="text" name="zipcode" id="zipcode" value="" size="10" />
> </dd>
> <dd id="city-element">
>  <input type="text" name="city" id="city" value="" />
> </dd>
>
>
> My CSS looks like this:
>
> ------------------
> fieldset dt {
>    width: 210px;
>    float: left;
> }
>
> fieldset dd {
>    float: left;
> }
>
> fieldset dd#zipcode-element {
>    width: 110px;
> }
> fieldset dd#city-element {
>    width: 330px;
> }
> fieldset input#zipcode {
>    width: 100px;
> }
> fieldset input#city {
>    width: 325px;
> }
>
> fieldset dd#city-element ul.errors {
>    margin-left: -115px;
> }
> ------------------
>
> It's kind of an ugly hack, especially the positioning of ul.errors - errors 
> of both input fields override each other. But as 
> Zend_Validate_NotEmpty::IS_EMPTY is the only possible error message in this 
> case, this doesn't matter and looks even better than two identical errors.
>
> take care
> Philip
>
>
>
> Am 14.05.2010 um 16:03 schrieb Eugene Morgan:
>
>> This is one way to do it:
>>
>> $city->removeDecorator('DtDdWrapper')
>>            ->addDecorator('HtmlTag', array(
>>                'tag' => 'dd'
>>            ));
>>
>> You'll get markup like this:
>> <dt id="zipcode-label"><label for="zipcode" class="required">Zipcode /
>> City</label></dt>
>> <dd id="zipcode-element">
>>   <input type="text" name="zipcode" id="zipcode" value="" />
>> </dd>
>> <dd>
>>   <input type="text" name="city" id="city" value="" />
>> </dd>
>>
>> Then you can use CSS to make that second <dd> display inline.
>>
>>
>> On Thu, May 13, 2010 at 4:50 PM, Philip Iezzi <[email protected]> wrote:
>>> Hi,
>>>
>>> What I'm trying to accomplish is to group two Zend_Form_Element_Text 
>>> elements that they show up on the same line.
>>> I'm styling my standard Zend_Form output (standard decorators) by CSS to 
>>> bring the form element's label to the left side of the input field.
>>>
>>>    $zipcode = new Zend_Form_Element_Text('zipcode', array('size' => 10));
>>>    $zipcode->setLabel('City')
>>>            ->setRequired(true);
>>>
>>>    $city = new Zend_Form_Element_Text('city');
>>>    $city->setLabel('Ort')
>>>         ->setRequired(true);
>>>
>>> The rendered form produces the following:
>>>
>>>  <dt id="zipcode-label"><label for="zipcode" 
>>> class="required">Zipcode</label></dt>
>>>  <dd id="zipcode-element">
>>>    <input type="text" name="zipcode" id="zipcode" value="" />
>>>  </dd>
>>>  <dt id="city-label"><label for="city" class="required">City</label></dt>
>>>  <dd id="city-element">
>>>    <input type="text" name="city" id="city" value="" />
>>>  </dd>
>>>
>>> Now I would like to group those two input fields together that they show up 
>>> on the same line, say:
>>>
>>>  <dt id="zipcode-label"><label for="zipcode" class="required">Zipcode / 
>>> City</label></dt>
>>>  <dd id="zipcode-element">
>>>    <input type="text" name="zipcode" id="zipcode" value="" />
>>>    <input type="text" name="city" id="city" value="" />
>>>  </dd>
>>>
>>> Removing the HtmlTag & Label decorators of $city doesn't do the trick...
>>>
>>>    $city->removeDecorator('HtmlTag')
>>>         ->removeDecorator('Label');
>>>
>>> How can I attach the $city element into the HtmlTag decorator (dd-Tag) of 
>>> the previous element? If possible, without building the whole form from 
>>> scratch with a ViewScript decorator.
>>>
>>> Thanks a lot
>>> Philip
>>
>
>



-- 
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