palAlaa
palAlaa

Reputation: 9858

Input field without label zend_form

I want to add input without label, I want to have HTML code like this flow

<label>sender</label>
<input type="text" name="senderNo"/>
<input type="text" name="senderName"/>

I make the decoration ​

  $mailSenderNo = new Zend_Form_Element_Text('mailSenderNo');
  $mailSenderNo->setLabel("الجهة المرسلة")
            ->setDecorators(
                    $this->setInlineDecorator("smallNoText")
    );
  $mailSenderName = new Zend_Form_Element_Text('mailSenderName');
  $mailSenderName->setDecorators(
                    $this->setInlineDecorator("largeText")
  );

and here's the decorator

function setInlineDecorator($className = null) {

    $inlineDecorator = null;
    if ($className == null) {
        $inlineDecorator = array(
            'ViewHelper',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'span')),
            array('Label', array('tag' => 'span', 'class' => 'elementTitle'))
        );
    } else {

        $inlineDecorator = array(
            'ViewHelper',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'span','class' => $className)),
            array('Label', array('tag' => 'span' ))
        );
    }
    return $inlineDecorator;
}

this results

<span id="mailSenderNo-label">
  <label class="optional" for="mailSenderNo">الجهة المرسلة</label>
</span>
<span class="smallNoText">
    <input id="mailSenderNo" type="text" value="" name="mailSenderNo">
</span>
<span id="mailSenderName-label">&nbsp;</span>  ?????  I don't what to have this span
<span class="largeText">
   <input id="mailSenderName" type="text" value="" name="mailSenderName">
</span>

this span

<span id="mailSenderName-label">&nbsp;</span>  

is for label for mailSenderName input, how can I remove this span????

Upvotes: 0

Views: 3602

Answers (1)

vascowhite
vascowhite

Reputation: 18440

Add this line:-

$mailSenderName->removeDecorator('Label');

That will remove the label from that element only.

Upvotes: 3

Related Questions