I was wondering is it ok to change implementation of parent class with child class data. I have situation of creating a child class (form) witch extends parent class (other form with same elements). If I dont change implementation of parent class some html Elements will have same id and both forms are on same page. So i am not sure is this legitimate way in terms of OOP rules. I was wondering why to inherit parent class when i want to change it?!
public function __construct(AddTaskErrors $addTaskErrors=null,
childData = [])
{
$this->addTaskErrors = $addTaskErrors;
$this->childData = $childData;
}
public function build(array $predefinedValues = [])
{//name id label value type za input
//input
$addTask = (isset($this->childData[self::ADD_TASK])) ? $this->childData[self::ADD_TASK] : self::ADD_TASK ;
$this->addElement(new InputTextElement(
$addTask ,
$addTask ,
$addTask ,
'', 'text', $predefinedValues));
$addTaskDeadline = (isset($this->childData[self::ADD_TASK_DEADLINE])) ? $this->childData[self::ADD_TASK_DEADLINE] : self::ADD_TASK_DEADLINE ;
$this->addElement(new InputTextElement(
$addTaskDeadline,
$addTaskDeadline,
$addTaskDeadline,
'', 'text', $predefinedValues));
//select
$addTaskPriority = (isset($this->childData[self::ADD_TASK_PRIORITY])) ? $this->childData[self::ADD_TASK_PRIORITY] : self::ADD_TASK_PRIORITY ;
$this->addElement(new SelectElement(
$addTaskPriority,
$addTaskPriority,
$addTaskPriority,
PriorityType::createFromDefaultValue(), $predefinedValues ));
return $this->getElements();
}