Add some html to Zend Forms
The only way I can think of at the moment is to add a dummy element to the form and remove all decorators except an 'HtmlTag' with the attributes you specified in your question. Removing the decorators means that the actual element will not be rendered - only the HtmlTag decorator will be rendered.
so assuming your form is $form:
$form->addElement(
'hidden',
'dummy',
array(
'required' => false,
'ignore' => true,
'autoInsertNotEmptyValidator' => false,
'decorators' => array(
array(
'HtmlTag', array(
'tag' => 'div',
'id' => 'wmd-button-bar',
'class' => 'wmd-panel'
)
)
)
)
);
$form->dummy->clearValidators();
Note that you want to prevent any validation of the element. This is only one way - there are likely others.
Output:
<div id="wmd-button-bar" class="wmd-panel"></div>
There is a good article describing decorators.
Insert custom HTML into Zend_Form
Use view script decorator . I assume you must be uploading image through an iframe . Which you can place it inside the phtml file of your view script decorator.
Inside your form class do .
$dec = new Zend_Form_Decorator_ViewScript();
$dec->setViewScript('Form.phtml');
$this->setDecorators(array($dec,'form'));
Inside Form.phtml to render element do
<?php echo $this->element->username ;?>
<?php echo $this->element->image ; ?>
and add your iframe as it is.
To know more about View script decorator
http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript
How to add html/text into a zend form htmlTag?
By using Zend_Form_Element_Text
you can insert your own html/text inside the form quite simply by doing the following.
$text = new Zend_Form_Element_Text('descCharsRemaining');
$text->setValue("<p>2000 Characters Remaining</p>")
->helper = 'formNote';
Then inserting the object into the addElements
array
$this->addElements(array(
// My other form elements
$text,
// My other form elements
UPDATE: I have discovered a more simplified way to do this by just including the following directly into the array
array(
'note',
'desc',
array(
'value' => '<p>2000 Characters Remaining</p>'
),
),
With the result being,
<dd id="descCharsRemaining-element">
<p>2000 Characters Remaining</p>
</dd>
How do I allow html tags in label for Zend form element using addElement()?
After calling addElement
fetch the label's decorator and change the escape setting:
$form->getElement('school_name')->getDecorator('label')->setOption('escape', false);
If you use this type of label a lot, you should consider writing a custom decorator.
Allow HTML on Zend form elements
Try to do like this:
$select = new Zend_Form_Element_Select('my_element', array(
'label' => 'My Element',
'description' => 'My link <a href="https://www.google.com/">here</a>',
'multiOptions' => array(
'opt_one' => 'Option One',
'opt_two' => 'Option Two'
)));
$select->getDecorator('Description')->setOption('escape', false);
$form->addElement($select);
Related Topics
Dynamically Changing Image Colours
Detect If Android App Has Been Installed on the Device Using a Mobile Web Page - PHP and Js
Understanding Imagemagick's Convert and Translating to Ruby Rmagick
Ruby and PHP Hmacs Not Agreeing
Using Regex to Filter Attributes in Xpath with PHP
How to Avoid Code Repetition with PHP SQL Prepared Statements
PHP Object Attribute with Dot in Name
Using Variables in MySQL Update (Php/Mysql)
Filling Gaps in Dates Returned from Database - Pure SQL Solution Possible
How to Find Number of Mondays or Tuesdays Between Two Dates
(Mysql, PHP) How to Get Auto_Increment Field Value Before Inserting Data
PHP SQL, Query Returns Only One Row of Data
$Stmt->Execute():How to Know If Db Insert Was Successful
Add Http:// Prefix to Url When Missing
How to Query Employee Details and Relate Their Performance Metrics