1
$sfKeyword = new Zend_Form_SubForm();

// text field
$tfKeyword = $sfKeyword->createElement('text', 'keyword');
$tfKeyword->setLabel('Search Keyword:');

// add elements
$sfKeyword->addElement($tfKeyword);
$sfKeyword->addElement('submit', 'submitSqlKeywordCheckerForm', array('label' => 'Check'));

// prepend labels        
$sfKeyword->setElementDecorators(array(
    'ViewHelper',
    'Errors',
    array('Label', array('placement' => 'prepend')),
));

I want to display a GUI like

[textfield label] [textfield] [submit button]

but the following gets displayed:

[textfield label] [textfield] [submit button label] [submit button]

The problem with the above code is that the submit button needs a label which is used on the button, but I don't want a label to be shown left to the button, which can't be circumvented with the decorator

array('Label', array('placement' => 'prepend')),

I basically have two options:

  1. Suppress the submit button's textual label (not the one inside the button) OR

  2. Delete the label decorator and manually add a simple text before the textfield

I have no idea how to add simple text to a form without a hidden input, which then must be labeled, too, so that doesn't help either.

How do I do it? Thanks

Kawu
  • 13,647
  • 34
  • 123
  • 195

1 Answers1

3

If you want to remove the label for submit button only try this:

$sfKeyword->getElement('submitSqlKeywordCheckerForm')->removeDecorator('label');

Hope this will be of help to you.

Marcin
  • 215,873
  • 14
  • 235
  • 294
  • IIRC I have tried this before, but wondered why it doesn't work. And I've just added this line and no it doesn't work, the check label is still shown. See here: http://dev.kawoolutions.com/Technology/Tools/SQL_Keyword_Checker – Kawu Jan 21 '11 at 13:47
  • I've also tried the solutions in http://stackoverflow.com/questions/481871/zend-framework-how-do-i-remove-the-decorators-on-a-zend-form-hidden-element but the label still persists. – Kawu Jan 21 '11 at 13:59
  • 1
    @Kawu. Did you add it after $sfKeyword->setElementDecorators(..)? It should be added after this method call. – Marcin Jan 21 '11 at 15:07
  • Thank you so much, I got it working now. Guess I'll have to get a better understanding of Zend_Form decorators and order stuff, which is still giving me problems in general. – Kawu Jan 21 '11 at 15:49