00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class Varien_Data_Form_Element_Multiline extends Varien_Data_Form_Element_Abstract
00033 {
00034 public function __construct($attributes=array())
00035 {
00036 parent::__construct($attributes);
00037 $this->setType('text');
00038 $this->setLineCount(2);
00039 }
00040
00041 public function getHtmlAttributes()
00042 {
00043 return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'maxlength');
00044 }
00045
00046 public function getLabelHtml($suffix = 0)
00047 {
00048 return parent::getLabelHtml($suffix);
00049 }
00050
00051 public function getElementHtml()
00052 {
00053 $html = '';
00054 $lineCount = $this->getLineCount();
00055
00056 for ($i=0; $i<$lineCount; $i++){
00057 if ($i==0) {
00058 if($this->getRequired()){
00059 $this->setClass('input-text required-entry');
00060 }
00061 }
00062 else {
00063 $this->setClass('input-text');
00064 }
00065 $html.= '<div class="multi-input"><input id="'.$this->getHtmlId().$i.'" name="'.$this->getName().'['.$i.']'
00066 .'" value="'.$this->getEscapedValue($i).'"'.$this->serialize($this->getHtmlAttributes()).' />'."\n";
00067 if ($i==0) {
00068 $html.= $this->getAfterElementHtml();
00069 }
00070 $html.= '</div>';
00071 }
00072 return $html;
00073 }
00074
00075 public function getDefaultHtml()
00076 {
00077 $html = '';
00078 $lineCount = $this->getLineCount();
00079
00080 for ($i=0; $i<$lineCount; $i++){
00081 $html.= ( $this->getNoSpan() === true ) ? '' : '<span class="field-row">'."\n";
00082 if ($i==0) {
00083 $html.= '<label for="'.$this->getHtmlId().$i.'">'.$this->getLabel()
00084 .( $this->getRequired() ? ' <span class="required">*</span>' : '' ).'</label>'."\n";
00085 if($this->getRequired()){
00086 $this->setClass('input-text required-entry');
00087 }
00088 }
00089 else {
00090 $this->setClass('input-text');
00091 $html.= '<label> </label>'."\n";
00092 }
00093 $html.= '<input id="'.$this->getHtmlId().$i.'" name="'.$this->getName().'['.$i.']'
00094 .'" value="'.$this->getEscapedValue($i).'"'.$this->serialize($this->getHtmlAttributes()).' />'."\n";
00095 if ($i==0) {
00096 $html.= $this->getAfterElementHtml();
00097 }
00098 $html.= ( $this->getNoSpan() === true ) ? '' : '</span>'."\n";
00099 }
00100 return $html;
00101 }
00102 }