开发者

set image after text box in zend form using zend decorator

开发者 https://www.devze.com 2023-02-26 05:19 出处:网络
I am using zend form and zend decorator to create a form. and I want to set a image after a text box. like this:

I am using zend form and zend decorator to create a form. and I want to set a image after a text box. like this:

set image after text box in zend form using zend decorator

I am using zend decorator but it is giving me like this:

set image after text box in zend form using zend decorator

I am using this code:

Class CountryController extends Zend_Controller_Action {

public $textimage = array(
    'ViewHelper',
     array('FormElements',array('tag'=>'img')),
    'FormElements',
    array(array('openerror' => 'HtmlTag'),array('tag' => 'td', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND,'width'=>'37%')),
    'Errors',
    array(array('closeerror' => 'HtmlTag'),array('tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),

    array(array('elementImg' => 'HtmlTag'), array('tag' => 'img','class'=>'imgpos')),

    array('HtmlTag', array('tag' => 'td','align'=>'left')),
    array('Label', array('tag' => 'td')),

    array(array('row' => 'HtmlTag'), array('tag' => 'tr','valign'=>'top','align'=>'right')),
    );

public $elementDecorators = array(
    'ViewHelper',
    'FormElements',
    array(array('openerror' => 'HtmlTag'),array('tag' => 'td', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),
    'Errors',
    array(array('closeerror' => 'HtmlTag'),array('tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),

    array('HtmlTag', array('tag' => 'td', 'class' => 'element','align'=>'left','colspan'=>'2')),
    array('Label', array('tag' => 'td')),
    array(array('row' => 'HtmlTag'), array('tag' => 'tr','valign'=>'top','align'=>'right')),
);

public $buttonDecorators = array(
    'ViewHelper',
    'Errors',
    'FormElements',
    array('HtmlTag', array('tag' => 'td','align'=>'left')),
    array(array('row' => 'HtmlTag'), array('tag' => 'div')),
);

public $addButton = array(
    'ViewHelper',
    'Errors',
    'FormElements',
    array('HtmlTag', array('tag' => 'td','align'=>'right')),
    array(array('row' => 'HtmlTag'), array('tag' => 'div')),
);

//======================add action for country============================

public function addAction() {

    $request = $this->getRequest();

    $form = new Zend_Form;
    $form->setAction('add')
        ->setMethod('POST')
        ->setAttrib('Name','addfrm')
        ->setAttrib('Id','addfrm');


    $form->addElements(array( 
             new Zend_Form_Element_Text('cou_name',array(
                    'decorators' => $this->textimage,

                  'required'   => true,
                  'label'      => 'Country Name :',
                    'class'=>'textpos',
                    'validator'=>'Alpha',
              )),
              new Zend_Form_Element_Textarea('description',array(
                    'decorators' => $this->textimage,
                  'required'   => true,
                  'label'      => 'Country Description :',
                    'rows'=>10,
                    'cols'=>40,
                    'validator'=>'NotEmpty',
                    'class'=>'textpos',
              )),
            new Zend_Form_Element_Checkbox('block',array(
                'decorators' => $this->elementDecorators,
                'Label'=>'Block :',
                'Value'=>'1',

              )),
              new Zend_Form_Element_Radio('block_r',array(
                'decorators' => $this->elementDecorators,
                'Label'=>'Block :',
                'multiOptions'=>array(0=>'Yes',1=>'No'),
                'Separator'=>'',
              )),
              new Zend_F开发者_如何转开发orm_Element_Submit('add',array(
                'decorators' => $this->addButton,
                'Label'=>'Add',
              )),
              new Zend_Form_Element_Button('back',array(
                'decorators' => $this->buttonDecorators,
                'Label'=>'Back',
                'onclick'=>'window.location="list"',
              )),
              ));


$form->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'table','align'=>'center','class'=>'tbcss','width'=>'84%')), 
    'Form',

));

    $this->view->assign('form',$form);

} }

I am using IE6.

the generated code is this:

<div class="container">
     <form enctype="application/x-www-form-urlencoded" action="add"
    method="post" Name="addfrm" Id="addfrm" name="">
      <table align="center" class="tbcss" width="84%">
    <tr valign="top" align="right">
        <td id="cou_name-label"><label for="cou_name" class="required">Country
        Name :</label></td>


>     <td align="left"><img class="imgpos"> <input type="text"
>                   name="cou_name" id="cou_name" value="" class="textpos"
>                   validator="Alpha" />
>               <td width="37%"></td>
>               </img></td>

    </tr>
    <tr valign="top" align="right">
        <td id="description-label"><label for="description"
            class="required">Country Description :</label></td>
        <td align="left"><img class="imgpos"> <textarea
            name="description" id="description" rows="10" cols="40"
            validator="NotEmpty" class="textpos"></textarea>
        <td width="37%"></td>
        </img></td>
    </tr>
    <tr valign="top" align="right">
        <td id="block-label"><label for="block" class="optional">Block
        :</label></td>
        <td class="element" align="left" colspan="2"><input type="hidden"
            name="block" value="0" /><input type="checkbox" name="block"
            id="block" value="1" checked="checked" />
        <td></td>
        </td>
    </tr>
    <tr valign="top" align="right">
        <td id="block_r-label"><label class="optional">Block :</label></td>
        <td class="element" align="left" colspan="2"><label
            for="block_r-0"><input type="radio" name="block_r"
            id="block_r-0" value="0" />Yes</label><label for="block_r-1"><input
            type="radio" name="block_r" id="block_r-1" value="1" />No</label>
        <td></td>
        </td>
    </tr>
    <div>
    <td align="right"><input type="submit" name="add" id="add"
        value="Add" /></td>
    </div>
    <div>
    <td align="left">
    <button name="back" id="back" type="button"
        onclick=
    window.location = "list";
Back</button>
    </td>
    </div>
</table>
</form>
</div>

Can anyone help me plz.


In your css just add

.imgpos {
    float: right;
}

Also you can try float .textpos to left

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号