HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/test.creativefellows.nl/vanlierop/src/InspectionController.php
<?php


final class InspectionController
{
	protected $fields = [];
	protected $method = "post";
	protected $action = "submissions/inspectie";
	protected $enctype = "";//"multipart/form-data";
	protected $form_error_message = "Niet alle velden in de inspectieaanvraag zijn ingevuld.";
	
	function __construct(array $fields)
	{	
	
		foreach($fields as $field)
		{
			$this->setField( new InspectionFieldData($field) );
		}
				
	}

	public function setField($field)
	{		
		$this->fields[] = $field;
	}
	
	
	public function fields()
	{		
		return $this->fields;
	}
	
	private function action()
	{
		return $this->action;
	}
	
	private function method()
	{
		return $this->method;
	}
	
	public function setMethod($method)
	{
		$this->method = $method;
	}

	public function render()
	{
		return $this->getHtml();
	}
	
	public function setType($enctype)
	{
		 $this->enctype = $enctype;
	}
	
	public function getHtml()
	{
	
		$html = '<form action="'. $this->action() .'" method="post" class="form form__inspectie" enctype="'. $this->enctype .'" data-abide novalidate>';
		
			foreach($this->fields as $field)
			{
				$html.= $field->getHtml();	
			}
			
			$html .= $this->formError();

		$html .= '</form>';	
		
		return $html;
		
		
	}
	public function modifyField($index,$changes)
	{	
		$this->fields[$index]->modify($changes);
	}
	
	private function formError()
	{
		return '<fieldset class="columns small-12"><div data-abide-error class="callout alert" aria-live="assertive" style="display: none;"><p><i class="fa fa-exclamation-triangle"></i> <strong>'. $this->form_error_message .'</strong></p></div></fieldset>';
	}
	
	
}