I am new at OOP and I wonder if the code below is OOP or it can be better and also what can be better?
class cForm{
private $_TagAction;
private $_TagMethod;
private $_TagName;
private $_TagExtraAttr;
//var form field
private $_FieldType;
private $_FieldName;
//var button
private $_ButtonValue;
private $_ButtonName;
public function __construct( $_TagAction , $_TagMethod , $_TagName , $_TagExtraAttr ){
$this->_TagAction = $_TagAction;
$this->_TagMethod = $_TagMethod;
$this->_TagName = $_TagName;
$this->_TagExtraAttr = $_TagExtraAttr;
}
public function getTagOpen(){
return '<form action="' . $this->_TagAction . '" method="' . $this->_TagMethod . '" name="' . $this->_TagName .'" ' . $this->_TagExtraAttr . '>' . PHP_EOL;
}
public function setFormField( $FieldType , $FieldName ){
$this->_FieldType = $FieldType;
$this->_FieldName = $FieldName;
}
public function getFormField(){
return '<input type="' . $this->_FieldType . '" name="' . $this->_FieldName . '" >'. PHP_EOL;
}
public function setButton( $ButtonValue , $ButtonName ){
$this->_ButtonValue = $ButtonValue;
$this->_ButtonName = $ButtonName;
}
public function getButton(){
return '<input type="submit" value="' . $this->_ButtonValue . '" name="'. $this->_ButtonName .'">';
}
public function getTagEnd(){
return '</form>' . PHP_EOL;
}
}
$objForm = new cForm( '/' , 'post' , 'test' , 'onsubmit="test"' );
echo $objForm->getTagOpen();
echo $objForm->setFormField('text','2');
echo $objForm->getFormField();
echo $objForm->setButton('test value','test name');
echo $objForm->getButton();
echo $objForm->getTagEnd();